Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: maxprogoji

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

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-07 15:22:49

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int sum = 0;
    string n;
    cin >> n;
    reverse(n.begin(),n.end());
    for(int i = 1; i < n.size(); i++) {
        if(i % 2 == 1) {
            for (char& j : to_string(((n[i] - '0') * 2))) sum += (j - '0');
        }
        else sum += (n[i] - '0');
    }
    (sum + (n[0] - '0')) % 10 == 0 ? cout << "yes" : cout << "no";
}