Cod sursa(job #736263)
Utilizator | Data | 18 aprilie 2012 11:54:12 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include<fstream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
long long exp(long long x,long long y){
if(y==0)return 1;
return x* exp(x,y-1);
}
int main(){
long long n,s,t;
fin>>t;
while(t){
fin>>n;
s=0;
for(int i=1;i<=n;i++)
s=s+exp(i,i);
fout<<s%10<<"\n";
t--;
}
return 0;
}