# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1276278 | SmuggingSpun | Lun (COCI19_lun) | C++20 | 2 ms | 576 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n, p;
cin >> n;
vector<int>d;
for(int i = 0; i < n; i++){
char c;
cin >> c;
if(c == 'x'){
d.push_back(-1);
p = i;
}
else{
d.push_back(c - '0');
}
}
for(int i = 0; i < 10; i++){
d[p] = i;
vector<int>D = d;
for(int j = n - 2; j > -1; j -= 2){
if((D[j] <<= 1) > 9){
D[j] -= 9;
}
}
int S = 0;
for(int j = 0; j + 1 < n; j++){
S += D[j];
}
if((S * 9) % 10 == D[n - 1]){
return cout << i, 0;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |