[ACM - 数论]A hard puzzle

A hard puzzle

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 25   Accepted Submission(s) : 7

Font: Times New Roman | Verdana | Georgia

Font Size:  

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

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

Author

eddy



解题思路:

一个数不管多大,我们关心的只是它的个位数,它再几次方也只关心个位的数字,个位数字0到9次方找周期,辅助图如下:

[ACM - 数论]A hard puzzle_第1张图片

根据规矩,可以很容易写出代码。


代码:

#include 
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {

            int t;
            t=a%10;//t为个位数
            switch(t)
            {
                case 0:{cout<<0<

运行截图:

[ACM - 数论]A hard puzzle_第2张图片

转载于:https://www.cnblogs.com/sr1993/p/3697824.html

你可能感兴趣的:([ACM - 数论]A hard puzzle)