Cod sursa(job #352589)
Utilizator | Data | 2 octombrie 2009 16:07:04 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.78 kb |
#include<fstream.h>
ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{int u,i,t,p,k,l;
long j,N;
f>>t;
for(i=1;i<=t;i++) { f>>N; u=0; for(j=1;j<=N;j++) {k=j%4;if(k==0)k=4;
p=1;
for(l=1;l<=k;l++)p*=j%10;
p%=10;
u+=p;
}
u%=10; g<<u<<"\n";
}
f.close();g.close(); return 0;
}