Cod sursa(job #949126)

Utilizator thewildnathNathan Wildenberg thewildnath Data 12 mai 2013 16:35:04
Problema Cifra Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<stdio.h>
#include<string.h>
int nr[105];
char n[105];

int main ()
{
    freopen("cifra.in","r",stdin);
    freopen("cifra.out","w",stdout);
    int t,i,j,l,x,y,s;
    scanf("%d",&t);
    for(i=1;i<=100;++i)
    {
        s=1;
        for(j=1;j<=i;++j)
            s=(s*i)%10;
        nr[i]=(s+nr[i-1])%10;
    }
    while(t)
    {
        t--;
        scanf("%s",&n);
        l=strlen(n);
        x=0;
        y=n[l-1]-'0';
        if(l>1)
            x=n[l-2]-'0';
        printf("%d\n",nr[x*10+y]);
    }
    return 0;

}