当前位置:网站首页>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;
}
边栏推荐
- 基于NCF的多模块协同实例
- Wechat reading notes of "work, consumerism and the new poor"
- 项目中遇到的线上数据迁移方案1---总体思路整理和技术梳理
- 2021 Hefei informatics competition primary school group
- Cbcgpprogressdlgctrl progress bar used by BCG
- There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
- 安徽 中安在线文旅频道推出“跟着小编游安徽”系列融媒体产品
- Shell programming core technology "three"
- How test engineers "attack the city" (Part I)
- C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
猜你喜欢

在线文本行固定长度填充工具

SSRS筛选器的IN运算(即包含于)用法

Oracle with as ORA-00903: invalid table name 多表报错

黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,

FPGA时序约束分享01_四大步骤简述

“只跑一趟”,小区装维任务主动推荐探索

BCG 使用之CBCGPProgressDlg进度条使用

Online text line fixed length fill tool

YOLOv5s-ShuffleNetV2

OpenCV的二值化处理函数threshold()详解
随机推荐
92.(cesium篇)cesium楼栋分层
Shell 编程核心技术《二》
指定输出的字符集
Shell 編程核心技術《四》
Euler function
Educational Codeforces Round 22 E. Army Creation
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
PolyFit软件介绍
偏移量函数及开窗函数
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
Swagger突然发癫
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
1007 Maximum Subsequence Sum(25 分)(PAT甲级)
添加命名空间声明
Shell programming core technology "four"
In flinksql, in addition to data statistics, is the saved data itself a state
Functional interface
HDU 1097 A hard puzzle
项目中遇到的线上数据迁移方案1---总体思路整理和技术梳理
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++