Pagini recente » Cod sursa (job #151952) | Cod sursa (job #953755) | Cod sursa (job #2017586) | Cod sursa (job #2370764) | Cod sursa (job #1907738)
#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(i
)%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;
}