Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: andamanlnwza007

Problemset: บาร์โค้ด

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-02 20:21:31

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int sumcheck1=0 ,sumcheck2=0,d=0;
	string bar,d1;
	cin>>bar;
	reverse(bar.begin(),bar.end());
	for (int i =0 ; i<13 ; i++){
		if((i+1)%2==0){
			d = stoi(bar.substr(i,1));
			sumcheck1+=d;
		}
		else if((i+1)%2!=0 and i>1){
			d1 = bar.substr(i,1);
			d = stoi(d1);
			sumcheck2+=d;
		}
	}
	sumcheck1*=3;
	string d2 = bar.substr(0,1);
	int digit = stoi(d2);
	if ((sumcheck1+sumcheck2+digit)%10==0){
		cout<<"YES";
	}
	else {
		cout<<"NO";
	}
	
}