杭电OJ 1097 A hard puzzle(我最后的博客水题报告)
来源:互联网 发布:k60单片机 编辑:程序博客网 时间:2024/05/16 14:07
A hard puzzle
Problem Description
lcy gives a hard puzzle tofeng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybodyobjects 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.Buteverybody is too lazy to slove this problem,so they remit to you who is wise.
Input
There are mutiple test cases. Each test casesconsists of two numbers a and b(0<a,b<=2^30)
Output
For each test case, you should output thea^b's last digit number.
Sample Input
7 66
8 800
Sample Output
9
6
这是我最后一次在博客上发水题的解题报告了。我虽然还会在杭电上刷水题,但是不会再做(过于简单的)水题的解题报告了。
当然,如果遇到困住我的水题(~~脸红),我还是会写出详细的解题报告,只不过不会把这道题放在水题的分类中,而是放在经验总结中。
就把这道无耻打表AC题,作为水题报告的终点吧。
</pre><pre>
<pre name="code" class="cpp">/*规律十分明显,但由于取余的关系,对周期T取余的值域为{0, 1, 2,...,T-1}, 末尾数字i的周期T的最后一个数在ans[i][0]中,而不是ans[i][T]中*/ #include <stdio.h>int ans[10][10] = {{0}, {1}, {6, 2, 4, 8}, {1, 3, 9, 7}, {6, 4}, {5}, {6}, {1, 7, 9, 3}, {6, 8, 4, 2}, {1, 9}};int T[10] = {1, 1, 4, 4, 2, 1, 1, 4, 4, 2};/*末尾数字i 对应的周期就是 T[i]*/int main(){int a, b;while (scanf("%d%d", &a, &b) != EOF) {a = a % 10;b = b % T[a];printf("%d\n", ans[a][b]);}return 0;}
- 杭电OJ 1097 A hard puzzle(我最后的博客水题报告)
- 杭电OJ(HDOJ)1097题:A hard puzzle(数论)
- 杭电1097 A hard puzzle
- 杭电 HDU 1097 A hard puzzle
- 【杭电】[1097]A hard puzzle
- [水题]杭电1097 A hard puzzle
- 杭电1097-A hard puzzle(快速幂)
- 杭电1097A hard puzzle(快速幂求余)
- HDOJ 1097 A hard puzzle 杭电 ACM
- 杭电acm1097 A hard puzzle
- A - A hard puzzle解题报告(陈渊)
- A - A hard puzzle解题报告(张宇)
- 1097 A hard puzzle
- 1097A hard puzzle
- 1097 A hard puzzle
- A hard puzzle(1097)
- 1097 A hard puzzle
- 1097 A hard puzzle
- light oj 1118
- 今天我开通了CSDN博客
- Qt 之QToolButton 实现QQ界面按钮效果
- HDU 1711 Number Sequence(KMP模板)
- struts2.5框架使用通配符指定方法常见错误
- 杭电OJ 1097 A hard puzzle(我最后的博客水题报告)
- 为了忘却的纪念
- [Lintcode]Best Time to Buy and Sell Stock
- 服务端ecs使用mongodb
- 获取往后n天的时间信息
- java代码模型5(代理设计模式)
- Duo
- Git 使用记录 - 基础
- 【工具】gdb多线程/多进程(守护进程)调试