Cod sursa(job #2220671)

Utilizator Laza_AndreiLazarescu Andrei Vlad Laza_Andrei Data 12 iulie 2018 12:38:52
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <cstdio>
#include <cstring>

using namespace std;

int uc(int n){
    int e,p,I;
    e=n%4;
    if(e==0) e==4;
    n=n%10;
    p=1;
    for(I=1;I<=e;++I)
        p=p*n;
    return p;
}
int v[101];
int main(){
    freopen("cifra.in","r",stdin);
    freopen("cifra.out","w",stdout);
    int t,i,l;
    char s[105];
    scanf("%d\n",&t);
    v[1]=1;
    for(i=2;i<=100;++i){
        v[i]=(v[i-1]+uc(i))%10;
    }
    while(t){
        gets(s);
        l=strlen(s);
        if(l==1){
            printf("%d\n",v[s[0]-'0']);
        }else{
            i=(s[l-2]-'0')*10+(s[l-1]-'0');
            printf("%d\n",v[i]);
        }
        --t;
    }
    return 0;
}