# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166127 | itiam | Lun (COCI19_lun) | C++11 | 2 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 <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
using namespace std;
int L[100];
int L2[10]={0,5,1,6,2,7,3,8,4,9};
int main(){
int N,par=0,parn=0,y,z;
char x;
cin >> N;
if (N%2==0) parn=1;
for (int i=0;i<N;i++){
cin >> x;
if (x!='x'){
y=2*((int)x-48);
if (y>=10) y=(y%10)+1;
z=(int)x-48;
}
else{
y=-1;
z=-1;
}
if (parn==1){
if ((i+1)%2>0){
L[i]=y;
if (y==-1) par=1;
}
else L[i]=z;
}
else if (parn==0){
if ((i+1)%2==0){
L[i]=y;
if (y==-1) par=1;
}
else L[i]=z;
}
}
int zb=0,zad,br=0,xx;
for (int i=0;i<N-1;i++){
if (L[i]==-1) continue;
zb+=L[i];
}
if (L[N-1]!=-1){
zad=L[N-1];
for (int i=0;i<10;i++){
br=((zb+i)*9)%10;
if (br==zad){
xx=i;
break;
}
}
if (par==1) xx=L2[xx];
}
else{
xx=((zb)*9)%10;
}
cout << xx;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |