Submission #159436

#TimeUsernameProblemLanguageResultExecution timeMemory
159436theknife2001Lun (COCI19_lun)C++17
40 / 50
3 ms504 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e5+55; string s; int main() { int n; cin>>n; cin>>s; reverse(s.begin(),s.end()); int pos; for(int k=0;k<n;k++) if(s[k]=='x') pos=k; int sum=0; int x; for(int i=1;i<n;i+=2) { if(i==pos) continue ; x=s[i]-'0'; x*=2; if(x>=10) x=x%10+x/10; sum+=x; } for(int i=2;i<n;i+=2) { if(i==pos) continue ; x=s[i]-'0'; sum+=x; } for(int i=0;i<10;i++) { s[pos]=i+'0'; if(pos==0) { cout<<(sum*9)%10<<endl; return 0; } if(pos%2) { x=i*2; if(x>=10) x=x/10+x%10; if(((sum+x)*9)%10==s[0]-'0') { cout<<i<<endl; return 0; } } if(((sum+i)*9)%10==s[0]-'0') { cout<<i<<endl; return 0; } } return 0; }

Compilation message (stderr)

lun.cpp: In function 'int main()':
lun.cpp:44:11: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(pos%2)
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...