Cod sursa(job #504363)

Utilizator DeadEyeNaiba Mihai Lucian DeadEye Data 27 noiembrie 2010 15:46:22
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.63 kb
#include<cstdio>
int x,xx,n,ii;
//int a[30001],b[30001];
const int c[21]={0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4,4};
int main()
{
	freopen("cifra.in","r",stdin);
	freopen("cifra.out","w",stdout);
	scanf("%d",&x);
	/*b[0]=0; a[0]=0;
	for(int i=1;i<=30000;i++)
	{
		ii=i%10;
		if(ii==0)
		{
			a[i]=0;
		}
		else if(ii==1)
		{
			a[i]=1;
		}
		else if(ii==2)
		{
			if(i%4==0)
			{
				a[i]=6;
			}
			else if(i%4==1)
			{
				a[i]=2;
			}
			else if(i%4==2)
			{
				a[i]=4;
			}
			else if(i%4==3)
			{
				a[i]=8;
			}
		}
		else if(ii==3)
		{
			if(i%4==0)
			{
				a[i]=1;
			}
			else if(i%4==1)
			{
				a[i]=3;
			}
			else if(i%4==2)
			{
				a[i]=9;
			}
			else if(i%4==3)
			{
				a[i]=7;
			}
		}
		else if(ii==4)
		{
			if(i%2==0)
			{
				a[i]=6;
			}
			else if(i%2==1)
			{
				a[i]=4;
			}
		}
		else if(ii==5)
		{
			a[i]=5;
		}
		else if(ii==6)
		{
			a[i]=6;
		}
		else if(ii==7)
		{
			if(i%4==0)
			{
				a[i]=1;
			}
			else if(i%4==1)
			{
				a[i]=7;
			}
			else if(i%4==2)
			{
				a[i]=9;
			}
			else if(i%4==3)
			{
				a[i]=3;
			}
		}
		else if(ii==8)
		{
			if(i%4==0)
			{
				a[i]=6;
			}
			else if(i%4==1)
			{
				a[i]=8;
			}
			else if(i%4==2)
			{
				a[i]=4;
			}
			else if(i%4==3)
			{
				a[i]=2;
			}
		}
		else if(ii==9)
		{
			if(i%2==0)
			{
				a[i]=1;
			}
			else if(i%2==1)
			{
				a[i]=9;
			}
		}
		b[i]=(b[i-1]+a[i])%10;
	}
	for(int i=1;i<=30000;i++)
		printf("%d,",b[i]);*/
	for(xx=1;xx<=x;xx++)
	{
		scanf("%d",&n);
		printf("%d\n",((n/20)*c[20]+c[n%20])%10);
	}
	return 0;
}