#include <bits/stdc++.h>
using namespace std;
int n;
string s;
bool check(){
int sm = 0;
for(int i=0;i<n-1;i++){
if(i%2 == n%2) sm += (2 * (s[i] - '0'))%10 + (2 * (s[i] - '0'))/10;
else sm += s[i] - '0';
}
return s[n-1] - '0' == (9*sm)%10;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> s;
int px = s.find('x');
for(char c='0';c<='9';c++){
s[px] = c;
if(check()){
cout<<c<<'\n';
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |