Pagini recente » Cod sursa (job #2099952) | Cod sursa (job #498420) | Cod sursa (job #1684918) | Cod sursa (job #1263500) | Cod sursa (job #199539)
Cod sursa(job #199539)
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;
long long n;
ifstream f("cifra.in");
ofstream g("cifra.out");
f>>t;
while(t--){
f>>n;
s=(cifra(n))%10;
g<<s<<endl;
}
return 0;
}