Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: peerapat_chinsuttiprapa

Problemset: ตรวจบัตรเครดิต

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-31 09:46:26

#include<bits/stdc++.h>
using namespace std;
string a,b;
int c[20],o=0,p=0,r=0,ln;
int main(){
	cin>>a;
	ln=int(a[a.length()-1]-'0');
	for(int i=1;i<a.length();i++){
		b+=a[a.length()-i-1];
		//cout<<b[i];
		c[i]=int(b[i-1]-'0');
		if(i%2!=0){
			c[i]*=2;
			o=c[i]%10; //lak nuay
			p=c[i]/10; // lak seb
			r=o+p+r;
		}
		else{
			r+=c[i];
		}
//		cout<<"r= "<<r<<" | c= "<<c[i]<<"\n";
	}
//	cout<<"------------------------------------------"<<"\n";
//	cout<<"r= "<<r<<" | c= "<<c<<"\n";
	if((10-(r%10))%10==ln){
		cout<<"yes";
	}
	else{
		cout<<"no";
	}
}