Cod sursa(job #796269)
Utilizator | Data | 10 octombrie 2012 22:08:43 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f;
ofstream g;
long int T,N,S,i,j,y,z;
int main()
{
f.open("cifra.in");
g.open("cifra.out");
f>>T;
z=1;
for(i=1;i<=T;i++){
f>>N;
S=0;
for(j=1;j<=N;j++){
for(y=1;y<=j;y++)
{
z=z*j;
z=z%10;
}
S=(S+z)%10;
z=1;
}
g<<S%10 <<endl;
}
return 0;
}