当前位置:网站首页>HDU 1097 A hard puzzle
HDU 1097 A hard puzzle
2022-07-04 19:37:00 【Acacia moon tower】
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
Answer key : This is a regular problem , The last number of each number changes periodically .
#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;
}
边栏推荐
- How test engineers "attack the city" (Part I)
- Specify the character set to output
- Shell 编程核心技术《三》
- Technologie de base de la programmation Shell IV
- Niuke Xiaobai monthly race 7 I new Microsoft Office Word document
- TCP两次挥手,你见过吗?那四次握手呢?
- 1008 Elevator(20 分)(PAT甲级)
- Opencv functions and methods related to binary threshold processing are summarized for comparison and use
- Leetcode fizzbuzz C # answer
- 函数式接口
猜你喜欢
随机推荐
关于判断点是否位于轮廓内的一点思考
FTP, SFTP file transfer
How to use async Awati asynchronous task processing instead of backgroundworker?
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
Master the use of auto analyze in data warehouse
C# 使用StopWatch测量程序运行时间
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
牛客小白月赛7 谁是神箭手
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
Leetcode fizzbuzz C # answer
《工作、消费主义和新穷人》的微信读书笔记
How test engineers "attack the city" (Part I)
安徽 中安在线文旅频道推出“跟着小编游安徽”系列融媒体产品
反射(一)
MySQL数据库基本操作-DDL | 黑马程序员
添加命名空间声明
“只跑一趟”,小区装维任务主动推荐探索
SSRS筛选器的IN运算(即包含于)用法
Shell programming core technology "I"
prometheus安装