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 ...
随机推荐
- Linux centos 6.5 搭建 svn服务器
实例:web1 1.安装subversion #yum install subversion #mkdir -p /oop/svn/ //创建svn目录 #chmod -R 777 /oop/svn ...
- 分布式事务_03_2PC框架raincat源码解析-事务提交过程
一.前言 前面两节,我们已经将raincat的demo工程启动,并简单分析了下事务协调者与事务参与者的启动过程. 这一节,我们来看下raincat的事务提交过程. 二.事务提交过程概览 1.二阶段对应 ...
- L116
7. You will discover surprising new ideas that are interesting and engaging Reading introduced me to ...
- 如何使用SOCKET 发送HTTP1.1 GET POST请求包
http://blog.csdn.net/yc0188/article/details/4741871 http://docs.linuxtone.org/ebooks/C&CPP/c/ch3 ...
- jquery ajax中使用jsonp的限制(转)
http://www.cnblogs.com/dudu/archive/2012/12/04/jquery_ajax_jsonp.html jsonp 解决的是跨域 ajax 调用的问题.为什么要跨域 ...
- PKUSC2018 Slay The Spire
有攻击牌和强化牌各 $n$ 张,强化牌可以让之后所有攻击牌攻击力乘一个大于 $1$ 的系数,攻击牌可以造成伤害 求所有“抽出 $m$ 张然后打 $k$ 张”能造成的伤害之和 $k,m,2n \leq ...
- WPF之ContextMenu的命定绑定
在WPF中右击菜单项的XMAL代码是: <ContextMenu x:Key="sampleContextMenu"> <MenuItem Header=&quo ...
- Broken Keyboard(模拟数组或者双重链表的运用)
这题我是大写的服气,辛辛苦苦搞了个双重链表结果还一直不对,不对就算了,书上源代码打进去还是不对,我能怎么办我也很无奈.不过这题还是让我对双重链表更加了解和运用了!还是可以的! You’re typin ...
- UOJ348. 【WC2018】州区划分
UOJ348. [WC2018]州区划分 http://uoj.ac/problem/348 分析: 设\(g(S)=(\sum\limits_{x\in S}w_x)^p[合法]\) \(f(S)\ ...
- LeetCode Repeated String Match
原题链接在这里:https://leetcode.com/problems/repeated-string-match/description/ 题目: Given two strings A and ...