Cod sursa(job #868113)
Utilizator | Data | 30 ianuarie 2013 17:52:35 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream f ("cifra.in");
ofstream g ("cifra.out");
int T,N,i,s,j;
int main()
{
f>>T;
for (i=1;i<=T;i++)
{
f>>N;
s=0;
for (j=1;j<=N;j++)
{
s=s+(int)pow(j,j)%10;
}
g<<s%10<<endl;
}
f.close();
g.close();
return 0;
}