当前位置:网站首页>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;
}
边栏推荐
- Shell 编程核心技术《一》
- 生成XML元素
- Pointnet/Pointnet++点云数据集处理并训练
- DeFi生态NFT流动性挖矿系统开发搭建
- 2019年蜀山区第十五届青少年信息学竞赛
- There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
- To sort out messy header files, I use include what you use
- sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
- 2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
- Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
猜你喜欢

升级智能开关,“零火版”、“单火”接线方式差异有多大?

MySQL数据库基本操作-DDL | 黑马程序员

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

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

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

神经网络物联网平台搭建(物联网平台搭建实战教程)

奥迪AUDI EDI INVOIC发票报文详解

Lex and yacc based lexical analyzer + parser

Bi skills - permission axis
![[release] a tool for testing WebService and database connection - dbtest v1.0](/img/4e/4154fec22035725d6c7aecd3371b05.jpg)
[release] a tool for testing WebService and database connection - dbtest v1.0
随机推荐
正则替换【JS,正则表达式】
《工作、消费主义和新穷人》的微信读书笔记
神经网络物联网应用技术学什么
偏移量函数及开窗函数
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
Leetcode ransom letter C # answer
使用SSH
千万不要只学 Oracle、MySQL!
The 15th youth informatics competition in Shushan District in 2019
资料下载 丨首届腾讯技术开放日课程精华!
redis分布式锁的8大坑总结梳理
Using FTP
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
876. Intermediate node of linked list
删除字符串中出现次数最少的字符【JS,Map排序,正则】
一文掌握数仓中auto analyze的使用
PolyFit软件介绍
The kth largest element in the array
BI技巧丨权限轴
整理混乱的头文件,我用include what you use