Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: ssens3

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-01 10:36:09

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string str; cin >> str; int r = 0; char l = str[15];
    str.erase(15,1); reverse(str.begin(), str.end());
    for (int i = 0; i < 15; i++){
        if (i % 2 == 0){
            if (str[i] >= '5') { r += 1 + (((str[i] - '0') - 5) * 2); }
            else r += (str[i] - '0') * 2;
            continue;
        }
        r += str[i] - '0';
    }
    cout << (((10 - (r % 10)) % 10 == l - '0') ? "yes" : "no");
}