HDU1097

来源:互联网 发布:中国经济史图书知乎 编辑:程序博客网 时间:2024/05/29 10:22

A hard puzzle




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 668 800
 

Sample Output
96
//HDU1097 基础题//A hard puzzle http://acm.hdu.edu.cn/showproblem.php?pid=1097//2017.06.23 by wyj#include#includeusing namespace std;int main(){int a, b, p;while (scanf("%d%d", &a, &b) != EOF){p = 1;a %= 10;b %= 4;if (b == 0)b = 4;while (b--){p *= a;}printf("%d\n", p % 10);}return 0;}
原创粉丝点击