Submission

Status:
[PPPPPPPPPP]

Score: 100

User: detectives_conan

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

Language: cpp

Time: 0.001 second

Submitted On: 2024-11-11 01:19:00

#include <stdio.h>
#include <string.h>

int main(){
    char crt[101];
    int a[101] = {0}, ans=  0;
    scanf("%s", crt);
    int idx = strlen(crt) - 1;
    for(int i = 0; i < strlen(crt) - 1; ++i){
        if(idx&1) a[idx] = (crt[i] - '0')*2;
        else a[idx] = (crt[i] - '0');
        idx--;
    }
    for(int i = 1; i <= strlen(crt) - 1; ++i){
        if(a[i] >= 10) ans += (1 + (a[i]%10));
        else ans += a[i];
    }
    if((10 - (ans%10))%10 == crt[strlen(crt) - 1] - '0') printf("yes\n");
    else printf("no\n");
}