Submission #103577

# Submission time Handle Problem Language Result Execution time Memory
103577 2019-03-31T17:00:26 Z kishtarn555 Lun (COCI19_lun) C++14
50 / 50
3 ms 384 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;
int N;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >>N;
    char c;
    long long sum = 0;
    long long pos;
    long long last;
    for (int i = 0; i < N; i++) {
        cin >> c;
        if (c=='x') {
            pos = i;
            continue;
        }
        if (i+1==N) {
            last = c-'0';
            continue;
        }
        if ( i%2!=N%2) {
            sum+=c-'0';
        } else {
//            cout <<(int)((c-'0')*2)<<endl;
            sum+= ((c-'0')*2)/10;
            sum +=((c-'0')*2)%10;
        }
    }
//    cout << sum<< endl;
    if (pos +1==N) {
        sum*=9;
        cout<<sum%10;
        return 0;

    }
//    c
//    cout << last<<endl;
    for (int i  = 0; i < 10; i ++) {
            long long ss = sum+i;
        if (pos %2!=N%2) {

        } else {
//            cout << "!";
            ss=sum + (2*i)/10+(2*i)%10;
        }

            if ((ss*9)%10==last) {
                cout << i;
                return 0;
            }

    }



    return 0;
}

Compilation message

lun.cpp: In function 'int main()':
lun.cpp:53:13: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if ((ss*9)%10==last) {
             ^~
lun.cpp:46:17: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (pos %2!=N%2) {
             ~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 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 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 356 KB Output is correct