Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: loop

Problemset: บาร์โค้ด

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-10 18:30:27

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

int main() {
    string s;
    cin >> s;
    int even = 0, odd = 0;
    for (int pos = 2; pos <= 13; pos++) {          // position 1 = rightmost digit (the check digit)
        int d = s[13 - pos] - '0';
        if (pos % 2 == 0) even += d; else odd += d;
    }
    int total = even * 3 + odd + (s[12] - '0');
    cout << (total % 10 == 0 ? "YES" : "NO") << '\n';
    return 0;
}