Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Sunsblad
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.002 second
Submitted On: 2026-09-30 11:28:51
#include<iostream>
#include<string>
using namespace std;
int main(){
string v;
int tot = 0;
cin>>v;
for(int i = 0; i < v.size() - 1; i++){
if(i % 2 == 0){
int tmp;
tmp = int(v[i])-int('0');
tmp *= 2;
//cout<<"tmp double = "<<tmp << '\n';
while(tmp != 0){
tot += tmp % 10;
tmp /= 10;
}
}else{
int tmp = v[i] - 48;
//cout<<"tmp = "<<tmp << '\n';
tot += int(v[i]) -48;
}
}
//cout<<v<<'\n';
//cout<<tot;
tot = (10 - (tot % 10)) % 10;
//cout<<int(v[15])-48;
if(tot == int(v[15])-48)cout<<"yes";else cout<<"no";
}