HDOJ 1097(阶乘尾数,水题)
2012-03-23 18:43
309 查看
A hard puzzle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16669 Accepted Submission(s): 5936
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
AC code:
#include <iostream> using namespace std; int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { a%=10; if(a==0||a==5||a==6||a==1) printf("%d\n",a); else if(a==4||a==9) { printf("%d\n",b%2==0?a*a%10:a); } else { if(b%4==1) printf("%d\n",a); else if(b%4==2) printf("%d\n",a*a%10); else if(b%4==3) printf("%d\n",a*a*a%10); else printf("%d\n",a*a*a*a%10); } } return 0; }
相关文章推荐
- HDOJ 1097(阶乘尾数,水题)
- HDOJ 1097 A hard puzzle 阶乘末尾数找规律
- hdoj1097水题
- HDOJ 3979 贪心 水题
- ACM水题系列 HDOJ 1064
- HDOJ 1097 A hard puzzle
- HDOJ 1097 A hard puzzle
- 求一个阶乘尾数0的个数(C语言实现)
- hdoj上的一些水题
- hdoj--1716--排列2(暴力水题)
- HDOJ 5831 Rikka with Parenthesis II (堆栈或者水题)
- hdoj 1016 回溯分析(以前遇到解空间为阶乘的时候比较害怕,现在好多了)
- HDOJ 题目2089 不要62 (打表 水题)
- hdoj 1097 A hard puzzle
- hdoj1097
- 水题 hdoj-2006奇数偶数判断小技巧 、 hdoj-2007
- HDOJ1014水题格式输出
- HDOJ 1097 A hard puzzle
- HDOJ 1280 前m大的数(水题)
- HDOJ2203亲和串 KMP水题