Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: denze
Problemset: ตรวจบัตรเครดิต
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-12 22:07:26
#include <bits/stdc++.h>
using namespace std;
char s[20];
int a[20];
int main()
{
scanf("%s", s);
int n = strlen(s);
int lastdigit = s[n - 1] - '0';
n--;
for (int i = 0; i < n; i++)
{
a[i] = s[i] - '0';
}
for (int i = 0; i < n / 2; i++)
{
swap(a[i], a[n - 1 - i]);
}
for (int i = 0; i < n; i += 2)
{
a[i] *= 2;
}
int r = 0;
for (int i = 0; i < n; i++)
{
if (a[i] > 9)
{
r += a[i] / 10;
r += a[i] % 10;
}
else
{
r += a[i];
}
}
if (lastdigit == (10 - (r % 10)) % 10)
{
printf("yes");
}
else
{
printf("no");
}
}
/*
3
*/