Submission #100265

#TimeUsernameProblemLanguageResultExecution timeMemory
100265amiLun (COCI19_lun)C++14
50 / 50
3 ms384 KiB
#include <bits/stdc++.h> #define sz(c) int(c.size()) #define rep(i,a,b) for (int i=a; i<(b); ++i) #define per(i,a,b) for (int i=(b)-1; i>=(a); --i) using namespace std; using ll = long long; bool valid(string s) { reverse(s.begin(),s.end()); int sum=0; rep(i,1,sz(s)) { int c=s[i]-'0'; if (i%2==1) { c*=2; sum+=c%10 + c/10; } else { sum+=c; } } return (sum*9)%10 == int(s[0]-'0'); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cout<<fixed<<setprecision(10); int n; string s; cin>>n>>s; int x=int(s.find('x')); rep(i,0,10) { s[x]=char('0'+i); if (valid(s)) { cout<<i<<"\n"; return 0; } } assert(false); }
#Verdict Execution timeMemoryGrader output
Fetching results...