Submission #103575

#TimeUsernameProblemLanguageResultExecution timeMemory
103575kukoLun (COCI19_lun)C++11
45 / 50
3 ms384 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...