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;
int main()
{
int a,b;
int round=;
int r[]={};
int i=;
while(cin>>a>>b)
{
r[]=a%;
r[]=(a%)*(a%)%;//这里是关键,开始是a*a%10,提交提示WA。
for(i=;;i++)
{
r[i]=r[i-]*(a%)%;
if(r[i]==r[])
{round=i-;break;}
}
if(b%round==)
cout<<r[round]<<endl;
else cout<<r[b%round]<<endl;
}
return ;
}

最新文章

  1. linux下压缩与解压(zip、unzip、tar)详解
  2. iwork 09 可以用的序列号
  3. Redis高级应用
  4. bookhub -- 扁平化本地电子书管理与分享工具
  5. 模型 - 视图 - 控制器(MVC)详解
  6. java_reflect_01
  7. JS高级程序设计学习笔记之基本包装类型
  8. D3D 光照和材料 小样例
  9. magento1.x 运行在 php7 优惠券的问题
  10. 【异构计算】GPU与CPU
  11. 从 0 开始手写一个 Mybatis 框架,三步搞定!
  12. 【HDU - 4927】Series 1
  13. chrome 调试功能使用说明
  14. Winform 设置控件值
  15. 在单链表的第i个位置后插入一个节点(阿里+腾讯等面试题总结)
  16. vue-cli3 使用mint-ui
  17. 20155212 2016-2017-2 《Java程序设计》第4周学习总结
  18. 【BZOJ4146】[AMPPZ2014]Divisors
  19. 【转】C++ 类访问控制public/private/protected探讨
  20. rdlc设置指定列隐藏

热门文章

  1. 分布式事务_02_2PC框架raincat源码解析-启动过程
  2. Spring_总结_04_高级配置(五)_运行时注入值
  3. 在VS2013上配置OpenCV1.0
  4. Arc066_F Contest with Drinks Hard
  5. Mayor&#39;s posters (线段树加离散化)
  6. Python环境的搭建
  7. Excel中函数row和column的特殊应用
  8. 五、Jmeter--关联(正则表达式)
  9. MySQL 预处理语句prepare、execute、deallocate的使用
  10. Composer + thinkphp5.1安装与使用