Pagini recente » Cod sursa (job #2976117) | Cod sursa (job #1901571) | Cod sursa (job #381396) | Cod sursa (job #77975) | Cod sursa (job #1907729)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int pow(int x)
{
int a=x,p=1;
x=x%10;
while(a>0)
{
p=p*x;
p=p%10;
a--;
}
return p;
}
int cifra(int x)
{
int b=1;
for(int i=2;i<=x;i++)
b=b+pow(x)%10;
return b;
}
int main()
{
int x,T;
f>>T;
for(int i=1; i<=T; i++)
{
f>>x;
g<<cifra(x)%10<<endl;
}
return 0;
}