Submission
Status:
[P-SSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: jamesz
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.005 second
Submitted On: 2026-09-30 14:31:31
#include<bits/stdc++.h>
using namespace std;
int a[40] = {0};
int main(){
string card;
cin>>card;
char T = card[15];
card[15] = 0;
for(int i = 0; i<16; i++){
int g = card[i];
a[15-i] = g;
}
for(int i = 0; i<16; i+=2){
a[i]*=2;
}
int Count;
Count = 0;
for(int i = 0; i<16; i++){
if(a[i]/10 > 0){
int RR = a[i];
a[i] = a[i]%10;
Count+=1;
}
}
for(int i = 0; i<40; i++){
Count+=a[i];
}
if((10-(Count % 10)) % 10 == T - '0'){
cout<<"yes";
}
else{
cout<<"no";
}
}