杭电OJ 1097 A hard puzzle(我最后的博客水题报告)
2016-08-08 23:07
453 查看
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题,作为水题报告的终点吧。
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 4000 ][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; }
相关文章推荐
- padding属性不起作用,原来设置scaletype为centerCrop了,要想两者同时作用,需加上android:cropToPadding="true"
- JS注意事项
- http协议学习系列
- UVA - 401 Palindromes
- 177.Which three statements are correct about temporary tables? (Choose three.)
- Android省市区三级联动滚轮选择(真实项目中提取出来的组件)
- YAML语言介绍
- TF-IDF与余弦相似性的应用(三):自动摘要
- 求出n个互异的数使得最小公倍数等于所有元素之和
- hdoj 5727 Necklace 二分图 全排列
- 2016 Personal Training #4 Div.2 A B C G H
- 学好Linux运维决心书
- TCP、UDP、IP 协议分析
- Oracle 建立索引及SQL优化
- LaTex学习笔记(1)——LaTeX文档插入图片的几种常用方法
- TF-IDF与余弦相似性的应用(二):找出相似文章
- UVA - 1586 Molar Mass
- 在java项目中使用log4j的实例
- PL/SQL基础
- 吴军《智能时代》读书笔记