Cod sursa(job #905063)
| Utilizator | Data | 5 martie 2013 15:08:36 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
long long t,i,j,a[100000000],s=0;
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);
cout<<s<<"\n";
g<<s%10<<"\n";
}
return 0;
}
