# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100265 | ami | Lun (COCI19_lun) | C++14 | 3 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |