当前位置:网站首页>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;
}
边栏推荐
- Send and receive IBM WebSphere MQ messages
- C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
- 国元期货是正规平台吗?在国元期货开户安全吗?
- [发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
- 更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
- 1672. Total assets of the richest customers
- Have you guys ever used CDC direct Mysql to Clickhouse
- BI技巧丨权限轴
- IBM WebSphere MQ retrieving messages
- One question per day (2022-07-02) - Minimum refueling times
猜你喜欢
PolyFit软件介绍
神经网络物联网是什么意思通俗的解释
Oracle with as ora-00903: invalid table name multi report error
There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
从实时应用角度谈通信总线仲裁机制和网络流控
Go microservice (II) - detailed introduction to protobuf
FPGA时序约束分享01_四大步骤简述
奥迪AUDI EDI INVOIC发票报文详解
关于判断点是否位于轮廓内的一点思考
【uniapp】uniapp开发app在线预览pdf文件
随机推荐
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
Use canal and rocketmq to listen to MySQL binlog logs
Shell 编程核心技术《一》
升级智能开关,“零火版”、“单火”接线方式差异有多大?
2021 合肥市信息学竞赛小学组
使用SSH
如何使用Async-Awati异步任务处理代替BackgroundWorker?
Oracle with as ora-00903: invalid table name multi report error
Cache é JSON uses JSON adapters
关于判断点是否位于轮廓内的一点思考
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
Wireshark网络抓包
Unity adds a function case similar to editor extension to its script, the use of ContextMenu
2022养生展,健康展,北京大健康展,健康产业展11月举办
26. Delete the duplicate item C solution in the ordered array
神经网络物联网是什么意思通俗的解释
PolyFit软件介绍
2021 Hefei informatics competition primary school group
Technology sharing | interface testing value and system
模板_大整数减法_无论大小关系