当前位置:网站首页>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;
}
边栏推荐
- Rookie post station management system based on C language
- 神经网络物联网是什么意思通俗的解释
- 2019年蜀山区第十五届青少年信息学竞赛
- 2022健康展,北京健博会,中国健康展,大健康展11月13日
- 小发猫物联网平台搭建与应用模型
- OpenCV的二值化处理函数threshold()详解
- 爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
- 26. 删除有序数组中的重复项 C#解答
- An example of multi module collaboration based on NCF
- [opencv introduction to mastery 9] opencv video capture, image and video conversion
猜你喜欢

小发猫物联网平台搭建与应用模型

Go microservice (II) - detailed introduction to protobuf

Pointnet/Pointnet++点云数据集处理并训练

每日一题(2022-07-02)——最低加油次数

Bi skills - permission axis

建立自己的网站(15)

英特尔集成光电研究最新进展推动共封装光学和光互连技术进步

使用canal配合rocketmq监听mysql的binlog日志
redis分布式锁的8大坑总结梳理

To sort out messy header files, I use include what you use
随机推荐
Nebula importer data import practice
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
How test engineers "attack the city" (Part I)
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
数组中的第K个最大元素
神经网络物联网应用技术就业前景【欢迎补充】
Pointnet/Pointnet++点云数据集处理并训练
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
神经网络物联网是什么意思通俗的解释
LM10丨余弦波动顺势网格策略
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
2022健康展,北京健博会,中国健康展,大健康展11月13日
[发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
测试工程师如何“攻城”(上)
工厂从自动化到数字孪生,图扑能干什么?
使用FTP
Detailed explanation of issues related to SSL certificate renewal
YOLOv5s-ShuffleNetV2
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
Shell 编程核心技术《三》