HDOJ 1097 A hard puzzle
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.
8 800
6
这道题也是一道求最后一个数字的,只是方式稍微改变了一下...
#include <iostream>
using namespace std;
int main()
{
int a,b;
int round=;
int r[]={};
int i=;
while(cin>>a>>b)
{
r[]=a%;
r[]=(a%)*(a%)%;//这里是关键,开始是a*a%10,提交提示WA。
for(i=;;i++)
{
r[i]=r[i-]*(a%)%;
if(r[i]==r[])
{round=i-;break;}
}
if(b%round==)
cout<<r[round]<<endl;
else cout<<r[b%round]<<endl;
}
return ;
}
HDOJ 1097 A hard puzzle的更多相关文章
- HDOJ 1097 A hard puzzle(循环问题)
Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how ...
- 【HDOJ】1097 A hard puzzle
题目和1061非常相似,几乎可以复用. #include <stdio.h> ][]; int main() { int a, b; int i, j; ; i<; ++i) { b ...
- hdu 1097 A hard puzzle 快速幂取模
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1097 分析:简单题,快速幂取模, 由于只要求输出最后一位,所以开始就可以直接mod10. /*A ha ...
- hdu 1097 A hard puzzle
Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how ...
- 【HDOJ】1857 Word Puzzle
trie树.以puzzle做trie树内存不够,从puzzle中直接找串应该会TLE.其实可以将查询组成trie树,离线做.扫描puzzle时注意仅三个方向即可. /* 1857 */ #includ ...
- HDOJ 1098 Ignatius's puzzle
Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice bu ...
- HDOJ 5411 CRB and Puzzle 矩阵高速幂
直接构造矩阵,最上面一行加一排1.高速幂计算矩阵的m次方,统计第一行的和 CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory ...
- HDOJ 1755 - A Number Puzzle 排列数字凑同余,状态压缩DP
dp [ x ] [ y ] [ z ] 表示二进制y所表示的组合对应的之和mod x余数为z的最小数... 如可用的数字为 1 2 3 4...那么 dp [ 7 ] [ 15 ] [ 2 ] = ...
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏
one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...
随机推荐
- requests 简单应用
http://docs.python-requests.org/zh_CN/latest/user/quickstart.html ,官方文档.自己有空看看顺便敲两下熟悉一下. 还有别把文件放的太深 ...
- nyoj-1099-Lan Xiang's Square(几何,水题)
题目链接 /* Name:nyoj-1099-Lan Xiang's Square Copyright: Author: Date: 2018/4/26 9:19:19 Description: 给4 ...
- 如何使用SOCKET 发送HTTP1.1 GET POST请求包
http://blog.csdn.net/yc0188/article/details/4741871 http://docs.linuxtone.org/ebooks/C&CPP/c/ch3 ...
- Android Volley完全解析(三),定制自己的Request
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17612763 经过前面两篇文章的学习,我们已经掌握了Volley各种Request ...
- 《Javascript高级程序设计》阅读记录(六):第六章 下
这个系列以往文字地址: <Javascript高级程序设计>阅读记录(一):第二.三章 <Javascript高级程序设计>阅读记录(二):第四章 <Javascript ...
- webpack 开发环境
当项目逐渐变大,webpack 的编译时间会变长,可以通过参数让编译的输出内容带有进度和颜色. $ webpack --progress --colors 如果不想每次修改模块后都重新编译,那么可以启 ...
- SpringMVC概要总结
架构流程 1. 用户发送请求至前端控制器DispatcherServlet 2. DispatcherServlet收到请求调用HandlerMapping处理器映射器. 3. 处理器映射器根据 ...
- mysql之 Innobackupex全备恢复(原理、演示)
一. Innobackupex恢复原理 After creating a backup, the data is not ready to be restored. There might b ...
- mysql之 double write 浅析
http://blog.itpub.net/22664653/viewspace-1140915/ 介绍double write之前我们有必要了解partial page write 问题 : ...
- BZOJ2342:[SHOI2011]双倍回文
浅谈\(Manacher\):https://www.cnblogs.com/AKMer/p/10431603.html 题目传送门:https://www.lydsy.com/JudgeOnline ...