您的位置:首页 > 其它

HDU 1061

2014-04-30 18:35 239 查看

#include<stdio.h>
#include<string.h>
int a[10];
int main()
{
    int T,n,i,k,temp,b,t;
    scanf("%d",&T);
    while(T--)
    {
        memset(a,0,sizeof(a));
        scanf("%d",&n);
        t = n;
        n %= 10;
        if(n==1||n==0)
        {
            printf("%d\n",n);
            continue ;
        }
        temp = 0;
        b = n;
        i = 0;
        while(temp!=n)
        {
            a[i++] = b;
            temp = (b*n)%10;
            b = temp;
        }
        k = t%i==0?i-1:t%i-1;
        printf("%d\n",a[k]);
    }
    return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: