Pagini recente » Istoria paginii runda/imded2/clasament | Cod sursa (job #847769) | Istoria paginii runda/leftbehind | Cod sursa (job #1223942) | Cod sursa (job #199543)
Cod sursa(job #199543)
using namespace std;
#include <iostream>
#include <fstream>
int power(int x,int y){
int d=x;
while(y--)
x=(x*d)%10;
return x;
}
int cifra(long long n){
int s=0;
while(n--)
s = s + (power(n,n))%10;
return s;
}
int main()
{
int t,s=0;
long long n;
ifstream f("cifra.in");
ofstream g("cifra.out");
f>>t;
while(t--){
f>>n;
s=(cifra(n%10))%10;
g<<s<<endl;
}
return 0;
}