Submission #103576

#TimeUsernameProblemLanguageResultExecution timeMemory
103576kishtarn555Lun (COCI19_lun)C++14
35 / 50
2 ms384 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...