Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: KanemiyaKana

Problemset: บาร์โค้ด

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-25 12:56:12

#include <iostream>
#include <string>
using namespace std;

string decipher(long long code)
{
    string codex = to_string(code);
    string flippedcodex = "";
    int firstpatternsum = 0;
    int firstpatternsumthreefold = 0;
    int secondpatternsum = 0;
    for (int i = codex.length() - 1; i >= 0; i--)
    {
        flippedcodex += codex[i];
    }
    // from location 1 skip 2 and go to 3 and so on
    for (int i = 0; i < flippedcodex.length(); i++)
    {
        if (i % 2 != 0)
        {
            firstpatternsum = firstpatternsum + (flippedcodex[i] - '0');
            firstpatternsumthreefold = firstpatternsum * 3;
        }
        else
        {
            if (i != 0)
            {
                secondpatternsum = secondpatternsum + (flippedcodex[i] - '0');
            }
        }
    }
    int totality = firstpatternsumthreefold + secondpatternsum;
    int victim = totality + (flippedcodex[0] - '0');
    if (victim % 10 == 0)
    {
        return "YES";
    }
    else
    {
        return "NO";
    }
}

int main()
{
    string input;
    cin >> input;
    long long intinput = stoll(input);
    if (input.length() != 13)
    {
        return 0;
    }
    else
    {
        string output = decipher(intinput);
        cout << output;
    }
}