Cod sursa(job #403829)
Utilizator | Data | 25 februarie 2010 13:20:01 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream.h>
long x,t,i,uc,e,s,p,y,n;
ifstream fin ("cifra.in");
ofstream fout ("cifra.out");
int main ()
{
fin>>t;
for (x=1;x<=t;x++)
{
fin>>n;
s=0;
for (i=1;i<=n;i++)
{
uc=i%10;
e=i%4;
if (uc)
{
if (e==0)
s=(s+uc*uc*uc*uc)%10;
else
{
p=1;
for (y=1;y<=e;y++)
p=p*uc;
s=(s+p)%10;
}
}
}
s=s%10;
fout<<s<<"\n";
}
return 0;
}