Cod sursa(job #739716)
Utilizator | Data | 23 aprilie 2012 19:24:56 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<iostream>
#include<fstream>
using namespace std;
int t,n,i,j,p,s,l;
int main()
{
ifstream f("cifra.in");
ofstream g("cifra.out");
f>>t;
for(l=1;l<=t;l++)
{
s=0;
f>>n;
for(i=1;i<=n;i++)
{
p=1;
for(j=1;j<=i;j++)
p*=i;
s+=p;
}
g<<s%10<<endl;
}
f.close();
g.close();
return 0;
}