#include <bits/stdc++.h>
using namespace std;
char account[128];
int main()
{
int n, d, sum = 0;
cin >> n;
cin >> account;
int multiplier = 1;
for( int i = n - 2; i >= 0; i -= 2 )
{
if( account[i] == 'x' )
{
multiplier = 2;
continue;
}
d = account[i] - '0';
d *= 2;
d = d%10 + d/10;
account[i] = d + '0';
}
for( int i = 0; i < n - 1; i++ )
if( account[i] != 'x' )
sum += account[i] - '0';
int newsum = 0, lastdigit = account[n - 1] - '0';
if( account[n - 1] != 'x')
{
for( int k = 0; k < 10; k++ )
{
newsum = sum + (k*multiplier)%10 + (k*multiplier)/10;
if( (newsum * 9) % 10 == lastdigit )
{
cout << k;
return 0;
}
}
}
else
{
srand(time(NULL));
if( rand() % 3 == 0 )
{
for( int k = 0; k < 10; k++ )
if( (sum * 9) % 10 == k )
{
cout << k;
return 0;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |