Cod sursa(job #427946)

Utilizator TranBachLamTran Bach Lam TranBachLam Data 28 martie 2010 16:56:16
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<stdio.h>
#include<math.h>
long r,j,i,uc,s,n,f[30001];
int main()
{
	freopen("cifra.in","r",stdin);
	freopen("cifra.out","w",stdout);
	scanf("%ld",&n);
    for(i=1;i<=n;++i)
		scanf("%ld",&f[i]);
	for(i=1;i<=n;++i)
		{
		s=0;
		for(j=1;j<=f[i];++j)
		{
		r=j%4;
		uc=j%10;
		if(r==0)
			 r=4;
		s=s+pow(uc,r);
		s=s%10;	
		}	
		printf("%ld\n",s);
	    }
	return 0;
}