# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159436 | theknife2001 | Lun (COCI19_lun) | C++17 | 3 ms | 504 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>
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |