Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Folk_DIWA

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-13 00:47:02

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main(){
    cin.tie(0)->sync_with_stdio(0);

    string s; cin >> s;
    int digit = (s.back() -'0');
    s.pop_back();

    reverse(s.begin(), s.end());
    vector <int> v;
    for(auto &c : s) v.push_back(c - '0');

    // for(auto &c : v) cout << c << ' ';

    for(int i=0; i<v.size(); i++){
        if(i%2 == 0) v[i] *= 2;
    }

    // for(auto &c : v) cout << c << ' ';

    string code = "";
    for(auto &x : v) code += to_string(x);
    // for(auto &c : code) cout << c << ' ';

    int sum = 0;
    for(auto &c : code) sum += c-'0';

    if( ((10 - (sum % 10)) % 10) == digit) cout << "yes";
    else cout << "no";

    // cout << digit;

    return 0;
}