Submission #103574

# Submission time Handle Problem Language Result Execution time Memory
103574 2019-03-31T16:24:18 Z kuko Lun (COCI19_lun) C++11
25 / 50
3 ms 384 KB
#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';
	for( int k = 0; k < 10; k++ )
	{
		newsum = sum + (k*multiplier)%10 + (k*multiplier)/10;
		if( (newsum * 9) % 10 == lastdigit )
		{
			cout << k;
			return 0;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct