Submission #104100

#TimeUsernameProblemLanguageResultExecution timeMemory
104100wiritos1Lun (COCI19_lun)C++98
50 / 50
2 ms384 KiB
#include<bits/stdc++.h> using namespace std; int main() { int a; string b; cin>>a>>b; bool p2=false; int sum=0; for(int c=0;c<a-1;c++) { if(b[c]=='x') { if(c%2==(a-1)%2) { p2=false; } else { p2=true; } } else { if(c%2==(a-1)%2) { sum+=b[c]-'0'; } else { if(b[c]<'5') { sum+=(b[c]-'0')*2; } else { sum+=((b[c]-'5')*2)+1; } } } //cout<<sum<<" "; } int temi; //cout<<sum<<"s"<<'\n'; for(int ga=0;ga<=9;ga++) { if(p2) { temi=ga*2; if(temi>=10) { temi%=10; temi++; } } else { temi=ga; } //cout<<temi<<" "; temi+=sum; temi*=9; temi%=10; //cout<<temi<<" "<<b[a-1]<<'\n'; if(b[a-1]=='x') { if((sum*9)%10==ga) { cout<<ga; return 0; } } else { if(temi==b[a-1]-'0') { cout<<ga; return 0; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...