Cod sursa(job #160603)
| Utilizator | Data | 16 martie 2008 12:41:19 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<iostream.h>
#include<stdio.h>
#include<math.h>
int main ()
{int T,S;
long int cif;
long long 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 ("%lld",&N);
for (;N>0;N--) {p=N,e=N;
while (p>4) p=p-4;
while (e>=10) e=e-10;
cif=pow(e,p);
cif=cif%10;
S=S+cif;
if (S>10) S=S/10;}
printf("%d",S); cout<<endl;}
return 0;}