Loading

数论 --- 找规律

A hard puzzle

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


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
 
【题目分析】
就是简单的找规律,规律很强。
 
#include<cstdio>
int fun[10][4]=
{
    0,0,0,0,
    1,1,1,1,
    2,4,8,6,
    3,9,7,1,
    4,6,4,6,
    5,5,5,5,
    6,6,6,6,
    7,9,3,1,
    8,4,2,6,
    9,1,9,1
};
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        printf("%d\n",fun[a%10][(b-1)%4]);
    }
    return 0;
}

 

 

 

 

 

 

 

posted @ 2014-05-27 16:06  北岛知寒  阅读(148)  评论(0编辑  收藏  举报