Cod sursa(job #523394)
| Utilizator | Data | 17 ianuarie 2011 22:08:22 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
#include <iostream>
#include <math.h>
using namespace std;
ifstream f ("cifra.in");
ofstream g ("cifra.out");
int main ()
{
int t,i,j,n,p=1,s=0,c,y=0;
int pow(int base, int power);
f>>t;
if (t<1) return 0;
if (t>30000) return 0;
for (j=1;j<=t;j++)
{
s=0;
f>>n;
if (n<1) return 0;
y=pow(10,100);
if (n >= y ) return 0;
for (i=1;i<=n;i++)
{
p=pow(i,i);
s=s+p;
}
c=(int)s%10;
g<<c<<endl;
}
}
