hdu1097 A hard puzzle

    xiaoxiao2021-03-25  24

     

    A hard puzzle

     

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 43138    Accepted Submission(s): 15623

     

     

    Problem Description

    lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin. this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.

     

     

    Input

    There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)

     

     

    Output

    For each test case, you should output the a^b's last digit number.

     

     

    Sample Input

     

    7 66 8 800

     

     

    Sample Output

     

    9 6

     

     

    // // Created by Admin on 2017/4/7. // #include<cstdio> int main(){ int a,b; while (~scanf("%d%d",&a,&b)){ a%=10; if(a==0||a==1||a==5||a==6)printf("%d\n",a); if(a==2){ if(b%4==1)printf("2\n"); if(b%4==2)printf("4\n"); if(b%4==3)printf("8\n"); if(b%4==0)printf("6\n"); } if(a==3){ if(b%4==1)printf("3\n"); if(b%4==2)printf("9\n"); if(b%4==3)printf("7\n"); if(b%4==0)printf("1\n"); } if(a==4){ if(b%2==1)printf("4\n"); if(b%2==0)printf("6\n"); } if(a==7){ if(b%4==1)printf("7\n"); if(b%4==2)printf("9\n"); if(b%4==3)printf("3\n"); if(b%4==0)printf("1\n"); } if(a==8){ if(b%4==1)printf("8\n"); if(b%4==2)printf("4\n"); if(b%4==3)printf("2\n"); if(b%4==0)printf("6\n"); } if(a==9){ if(b%2==1)printf("9\n"); if(b%2==0)printf("1\n"); } } return 0; }

     

     

     

    转载请注明原文地址: https://ju.6miu.com/read-300027.html

    最新回复(0)