当前位置:网站首页>HDU 1097 A hard puzzle
HDU 1097 A hard puzzle
2022-07-04 17:58:00 【相思明月楼】
Problem Description
lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects 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.But everybody is too lazy to slove this problem,so they remit to you who is wise.
Input
There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)
Output
For each test case, you should output the a^b's last digit number.
Sample Input
7 66
8 800
Sample Output
9
6
题解:这是一道规律题,每个数的最后一个数按周期变化。
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll a, b;
int ans[][5] = {
{0},{1},{2,4,8,6},{3,9,7,1},{4,6},{5},{6},{7,9,3,1},{8,4,2,6},{9,1}};
while(cin>>a>>b) {
a %= 10;
if(a==0||a==1||a==5||a==6) {
cout<<ans[a][0]<<endl;
} else if(a==4||a==9) {
if(b%2==0) {
cout<<ans[a][1]<<endl;
} else {
cout<<ans[a][(b%2)-1]<<endl;
}
} else if(a==2||a==3||a==7||a==8) {
if(b%4==0) {
cout<<ans[a][3]<<endl;
} else {
cout<<ans[a][(b%4)-1]<<endl;
}
}
}
return 0;
}
边栏推荐
- 物联网应用技术的就业前景和现状
- 26. Delete the duplicate item C solution in the ordered array
- Unity adds a function case similar to editor extension to its script, the use of ContextMenu
- Nebula importer data import practice
- 发送和接收IBM WebSphere MQ消息
- Stream流
- 反射(一)
- Have you guys ever used CDC direct Mysql to Clickhouse
- 神经网络物联网应用技术就业前景【欢迎补充】
- 使用SSH
猜你喜欢
升级智能开关,“零火版”、“单火”接线方式差异有多大?
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
在线文本行固定长度填充工具
千万不要只学 Oracle、MySQL!
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
MySQL数据库基本操作-DDL | 黑马程序员
FPGA时序约束分享01_四大步骤简述
OpenCV的二值化处理函数threshold()详解
神经网络物联网应用技术就业前景【欢迎补充】
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
随机推荐
偏移量函数及开窗函数
The difference and usage between substr (), slice (), and substring () in the string interception methods of "understand series after reading"
DeFi生态NFT流动性挖矿系统开发搭建
prometheus安装
C#实现定义一套中间SQL可以跨库执行的SQL语句(案例详解)
Go microservice (II) - detailed introduction to protobuf
MySQL数据库基本操作-DDL | 黑马程序员
Shell 编程核心技术《三》
如何使用Async-Awati异步任务处理代替BackgroundWorker?
Wireshark网络抓包
升级智能开关,“零火版”、“单火”接线方式差异有多大?
【uniapp】uniapp开发app在线预览pdf文件
LeetCode FizzBuzz C#解答
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
生成XML元素
其他InterSystems %Net工具
小发猫物联网平台搭建与应用模型
函数式接口
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
长城证券开户安全吗 买股票怎么开户