Pagini recente » Cod sursa (job #2424212) | Cod sursa (job #1359723) | Cod sursa (job #1970808) | Cod sursa (job #480923) | Cod sursa (job #523394)
Cod sursa(job #523394)
#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;
}
}