Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: polikanta
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.002 second
Submitted On: 2026-09-27 19:19:30
#include<iostream>
using namespace std;
int main(){
string card;
cin >> card;
int last = card[15] - '0';
int r = 0;
int count = 1;
for (int i = 14; i >= 0; i--){
int x = card[i] - '0';
if (count % 2 != 0){
x = x * 2;
}
if (x >= 10){
r = r + (x / 10)+(x % 10);
}
else{
r = r + x;
}
count = count + 1;
}
int check = (10 - (r % 10))% 10;
if (check == last){
cout << "yes" << endl;
}
else{
cout << "no" << endl;
}
}