Cod sursa(job #354724)
Utilizator | Data | 9 octombrie 2009 11:58:40 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.33 kb |
#include <fstream>
#include <math.h>
using namespace std;
unsigned long suma(int a)
{ unsigned long i,s=0;
for (i=1;i<=a;i++)
s=s+pow(i,i);
return s%10;
}
int main()
{ifstream f;
ofstream g;
unsigned long t,i,a;
f.open("cifra.in");
g.open("cifra.out");
f>>t;
for (i=1;i<=t;i++)
{f>>a ; g<<suma(a)<<endl;}
return 0;
}