Cod sursa(job #198846)
| Utilizator | Data | 15 iulie 2008 13:08:06 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 1.82 kb |
#include <stdio.h>
int f(short int x,long y)
{
switch (x)
{
case 0: return 0;
case 1: return 1;
case 2: switch (y%4)
{
case 1: return 2;
case 2: return 4;
case 3: return 8;
case 0: return 6;
}
case 3: switch (y%4)
{
case 1: return 3;
case 2: return 9;
case 3: return 7;
case 0: return 1;
}
case 4: switch (y%2)
{
case 1: return 4;
case 0: return 6;
}
case 5: return 5;
case 6: return 6;
case 7: switch (y%4)
{
case 1: return 7;
case 2: return 9;
case 3: return 3;
case 0: return 1;
}
case 8: switch (y%4)
{
case 1: return 8;
case 2: return 4;
case 3: return 2;
case 0: return 6;
}
case 9: switch (y%2)
{
case 1: return 9;
case 0: return 1;
}
}
}
int main()
{
int A[100],i,n,x;
A[0]=0;
for (i=1;i<101;i++) A[i] = (A[i-1]+f(i%10,i))%10;
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d",&n);
for (;n;n--)
{
scanf("%d",&x);
printf("%d\n",A[x%100]);
}
}
