Submission #100302

# Submission time Handle Problem Language Result Execution time Memory
100302 2019-03-10T10:43:05 Z tpoppo Lun (COCI19_lun) C++14
50 / 50
4 ms 384 KB
#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;
}
# Verdict Execution time Memory 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