Cod sursa(job #905067)
Utilizator | Bratie Fanut bratiefanut | Data | 5 martie 2013 15:09:39 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
long long t,i,j,a[100000000],s;
long long putere(long long int x,long long y)
{
long long a=1;
while(y>0)
if(y%2==0)
{
x=(x*x);
y=y/2;
}
else
{
a=(a*x);
y--;
}
return a;
}
int main()
{
f>>t;
for(i=1;i<=t;i++)
{
s=0;
f>>a[i];
for(j=1;j<=a[i];j++)
s=s+putere(j,j);
g<<s%10<<"\n";
}
return 0;
}