Pagini recente » Cod sursa (job #1919377) | Cod sursa (job #2770804) | Cod sursa (job #214474) | Cod sursa (job #2256256) | Cod sursa (job #45995)
Cod sursa(job #45995)
#include <stdio.h>
#include <math.h>
FILE *f=fopen("cifra.in","r"), *g=fopen("cifra.out","w");
int put(int x)
{
int p,i;
p=x;
x%=10;
if (p%4==0)
x=pow(x,4);
else
x=pow(x,p%4);
x%=10;
return x;
}
int main()
{
long s,n,o;
int i,x,t,oo,j;
fscanf(f,"%d",&t);
for (i=1;i<=t;i++)
{
s=0;
fscanf(f,"%ld",&n);
o=n/20;
oo=n%20;
s=o*6;
s=s%10;
for (j=1;j<=oo;j++)
{
s+=put(j);
s=s%10;
}
fprintf(g,"%d\n",s);
}
return 0;
}