Pagini recente » Cod sursa (job #249181) | Cod sursa (job #2565005) | Cod sursa (job #249183) | Cod sursa (job #199533) | Cod sursa (job #199544)
Cod sursa(job #199544)
using namespace std;
#include <iostream>
#include <fstream>
int power(int x,int y){
int d=x;
y--;
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;
}