Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: korn234

Problemset: ตรวจบัตรเครดิต

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-13 19:03:19

#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string card;
    cin>>card;
    int sum=0;
    long long check = card[15]-'0';
    for (int i = 14; i >= 0; i--) {
        int d = card[i] - '0';
        if (i%2==0) {
            d=d*2;
            if (d>=10){
                d=d/10+d%10;
            }
        }
        sum+=d;
    }
    if ((10-(sum%10))%10==check){
        cout<<"yes";
    }
    else {
        cout<<"no";
    }
}