Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: cheeseycheese05

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-13 17:49:53

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    string credit_card;
    cin >> credit_card;
    int temp = credit_card.back() - '0';
    credit_card.pop_back();
    reverse(credit_card.begin(), credit_card.end());
    for(int i = 0; i < credit_card.length(); i++) if(i % 2 == 0) credit_card[i] = ((credit_card[i] - '0') * 2 + ((((credit_card[i] - '0') * 2 ) > 9) ? - 9 : + 0)) + '0';
    int r = 0;
    for(char& digit : credit_card) r += digit - '0';
    cout << (((10 - (r % 10)) % 10 == temp) ? "yes" : "no");
    return 0;
}