Pagini recente » Cod sursa (job #2292156) | Cod sursa (job #446729) | Statistici Iancu Matei (mardeias) | Borderou de evaluare (job #2639292) | 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;
}