Submission #166127

#TimeUsernameProblemLanguageResultExecution timeMemory
166127itiamLun (COCI19_lun)C++11
50 / 50
2 ms504 KiB
#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)

lun.cpp: In function 'int main()':
lun.cpp:56:23: warning: 'xx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (par==1) xx=L2[xx];
                     ~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...