Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Gundhon
Problemset: บาร์โค้ด
Language: cpp
Time: 0.003 second
Submitted On: 2026-10-07 15:55:37
#include <iostream>
using namespace std;
int main(){
string x;
cin >> x;
if(x.length() != 13){
return 0;
}
int y = x.length();
int sum1 = 0, sum2 = 0; //sum1 = odd sum2 = even
for(int i = y-1; i >= 0; i--){
if (i % 2 != 0){
sum2 += x[i] - '0';
}
else if(i % 2 == 0 && i <= 10){
sum1 += x[i] - '0';
}
}
int z = (sum2*3 + sum1) + x[12] - '0';
if(z%10 == 0) cout << "YES";
else cout << "NO";
return 0;
}