Cod sursa(job #160610)
| Utilizator | Data | 16 martie 2008 12:56:37 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include<iostream.h>
#include<stdio.h>
#include<math.h>
int main ()
{int T,S,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;
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;}