当前位置:网站首页>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;
}
边栏推荐
- 更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
- YOLOv5s-ShuffleNetV2
- 自由小兵儿
- An example of multi module collaboration based on NCF
- 添加命名空间声明
- BI技巧丨权限轴
- The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
- 876. 链表的中间结点
- 爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
- Stream流
猜你喜欢
redis分布式锁的8大坑总结梳理

神经网络物联网是什么意思通俗的解释

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

One question per day (2022-07-02) - Minimum refueling times

Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?

Nebula importer data import practice

Opencv functions and methods related to binary threshold processing are summarized for comparison and use

Wireshark网络抓包

OpenCV的二值化处理函数threshold()详解

神经网络物联网应用技术就业前景【欢迎补充】
随机推荐
其他InterSystems %Net工具
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
One question per day (2022-07-02) - Minimum refueling times
LeetCode FizzBuzz C#解答
数组中的第K个最大元素
876. Intermediate node of linked list
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import 'fmt' func
Shell 編程核心技術《四》
Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
如何使用Async-Awati异步任务处理代替BackgroundWorker?
Shell 编程核心技术《四》
【uniapp】uniapp开发app在线预览pdf文件
在线SQL转Excel(xls/xlsx)工具
利用策略模式优化if代码【策略模式】
奥迪AUDI EDI INVOIC发票报文详解
正则替换【JS,正则表达式】
SSL证书续费相关问题详解
Use canal and rocketmq to listen to MySQL binlog logs
“只跑一趟”,小区装维任务主动推荐探索
Shell 编程核心技术《三》