Cod sursa(job #1157121)

Utilizator torckySuciu Victor torcky Data 28 martie 2014 11:41:11
Problema Cifra Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <cstdio>
#include <cstring>
using namespace std;
int sp[105];
char s[105];
int main()
{
    freopen("cifra.in","r",stdin);
    freopen("cifra.out","w",stdout);
    int n,prod,nrc,x;
    scanf("%d\n",&n);
    sp[0]=0;
    for(int i=1;i<100;i++){
        prod=1;
        for(int j=1;j<=i;j++){
            prod=(prod*i)%10;
        }
        sp[i]=(sp[i-1]+prod)%10;
    }
    for(int i=1;i<=n;i++){
        gets(s+1);
        s[0]='0';
        nrc=strlen(s+1);
        x=(s[nrc-1]-'0')*10+(s[nrc]-'0');
        printf("%d\n",sp[x]);
    }
    return 0;
}