Cod sursa(job #1725011)
| Utilizator | Data | 4 iulie 2016 18:39:42 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
int i,n,lu,c,s,r;
char st[110];
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d",&n);
for(i=1; i<=n; ++i)
{
scanf("%s",&st);
lu=strlen(st);
c=st[lu-1]-'0';
r=i%4;
if(r==2)c=c*c%10;
else if(r==3)c=c*c*c%10;
else if(r==0)c=c*c*c*c%10;
s+=c;
s%=10;
printf("%d\n",s);
}
return 0;
}
