Cod sursa(job #160611)
Utilizator | Data | 16 martie 2008 12:59:23 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include<iostream.h>
#include<stdio.h>
#include<math.h>
int main ()
{int T,S,cif;
long int N,p,e;
freopen("cifra.in", "rt", stdin);
freopen("cifra.out", "wt", stdout);
scanf ("%d",&T);
for (S=0;T>0;T--,S=0) {scanf ("%ld",&N);
for (;N>0;N--) {p=N-1,e=N;
p=p%4+1;
e=e%10;
for (cif=1;p>0;p--) {cif=cif*e;
if (cif>=10) cif=cif-10;}
S=S+cif;
if (S>10) S=S/10;}
printf("%d",S); cout<<endl;}
return 0;}