Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Boeing12345
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.003 second
Submitted On: 2026-09-24 11:23:09
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
string a = "";
string b = "";
string d = "";
int check;
int i;
int R = 0;
vector <int> c;
vector <int> m;
cin >> a;
if(a.length() == 16){
b = a.substr(0, 15);
check = a[15] - '0';
reverse(b.begin(), b.end());
for(i = 0; i <= 14; i++){
if(i % 2 == 1){
c.push_back(b[i] - '0');
} else if(i % 2 == 0){
c.push_back(2 * (b[i] - '0'));
}
}
for(i = 0; i <= 14; i++){
d = d + to_string(c[i]);
}
for(i = 0; i <= d.length() - 1; i++){
R = R + (d[i] - '0');
}
if(((10-(R % 10)) % 10) == check){
cout << "yes";
} else {
cout << "no";
}
}
}