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 ...
随机推荐
- 【新手专属】IntelliJ IDEA删除项目
这两天刚从Eclipse转手IDEA,每次都是直接删项目文件,后来百度一下才明白原来应该这样~~~ IntelliJ IDEA 删除项目,共三步: 第一步:记住当前项目文件路径1,然后点击file-- ...
- kylin_学习_02_kylin使用教程
一. 二.参考资料 1.kylin从入门到实战:实际案例
- centos下环境变量配置
export JAVA_HOME=/usr/local/jdk1.7.0_80export JRE_HOME=/usr/local/jdk1.7.0_80/jreexport CLASSPATH=.: ...
- 排列(加了点小set就过了,哈哈哈)
Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数. 输入描述: 1 2 3 4 1 1 2 3 0 1 2 3 0 0 0 0输出 ...
- 了解Unity中的多线程及使用多线程
http://blog.csdn.net/hany3000/article/details/16917571 如果你想在游戏中使用多线程,你应该看看这篇文章,线程是一个相当复杂的话题,但如果你掌握了它 ...
- Maven里头的pom.xml配置详解
正常的pom配置文件如下所示: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http ...
- redis之 centos 6.7 下安装 redis-3.2.5
前期准备:1. 操作系统需要安装 gcc 包 与 TCL 库, 通过配置本地 yum 源 ,yum -y install gcc . yum -y install tcl安装2. 下载 redis ...
- array_diff函数的注意事项
array_diff — 计算数组的差集 说明: array array_diff ( array $array1 , array $array2 [, array $... ] ) 对比返回在 ar ...
- centos 虚拟机联网
在windows主机安装centos虚拟机后,遇到虚拟机连接外网问题. 解决方案:http://blog.csdn.net/pang040328/article/details/12427359 经过 ...
- 第15届浙江省赛 D Sequence Swapping(dp)
Sequence Swapping Time Limit: 1 Second Memory Limit: 65536 KB BaoBao has just found a strange s ...