Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: navysrimuang
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.002 second
Submitted On: 2025-09-26 22:59:10
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
string s;
cin >> s;
int key = s[15] - '0';
int sum = 0;
for(int i = 0;i<15;i++){
//take sum of normies
if(i%2 != 0){
sum += s[i] - '0';
}else{
int tmp = s[i] - '0';
tmp*=2;
string stmp = to_string(tmp);
for(int j = 0;j<stmp.length();j++){
sum += stmp[j] - '0';
}
}
//if its every odd *2 and take sum
}
int ans = (10 - (sum%10))%10;
if(ans == key){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
return 0;
}