Submission #1106384

#TimeUsernameProblemLanguageResultExecution timeMemory
1106384SalihSahinLun (COCI19_lun)C++14
50 / 50
1 ms504 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int mod = 1e9 + 7; const int inf = 1e17; const int N = 2e5+5; int op(int num){ int x = 0; while(num > 0){ x += num % 10; num /= 10; } return x; } int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n; cin>>n; string s; cin>>s; int ans = -1; for(int ch = 0; ch <= 9; ch++){ int val = 0; for(int i = s.size()-2; i >= 0; i -= 2){ if(s[i] == 'x') val += op(ch * 2); else val += op((s[i] - '0') * 2); } for(int i = s.size()-3; i >= 0; i -= 2){ if(s[i] == 'x') val += ch; else val += (s[i] - '0'); } int check = 0; if(s[s.size()-1] == 'x') check = ch; else check = s[s.size()-1] - '0'; if((val * 9)%10 == check){ ans = ch; break; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...