A^B Problem

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描写叙述
Give you two numbers a and b,how to know the a^b's the last digit number.It looks so easy,but everybody is too lazy to slove this problem,so they remit to you who is wise.

输入
There are mutiple test cases. Each test cases consists of two numbers a and b(0<=a,b<2^30)
输出
For each test case, you should output the a^b's last digit number.
例子输入
7 66
8 800
例子输出
9
6
提示
There is no such case in which a = 0 && b = 0。
来源

source=hdu" style="text-decoration:none; color:rgb(55,119,188)">hdu

上传者
ACM_丁国强


#include <stdio.h>
int main()
{
int a,b,_a,s;
while(scanf("%d %d",&a,&b)!=EOF)
{
if(a==0&&b==0)
break;
s=1;
while(b)
{
if(s>=10)
s=s%10;
if(a>=10)
a=a%10;
if(b%2==1)
s=s*a;
a=a*a;
b=b/2;
}
if(s>=10)
s=s%10;
printf("%d\n",s);
}
return 0;
}

nyoj473 A^B Problem (高速幂)的更多相关文章

  1. LightOJ 1070 - Algebraic Problem 矩阵高速幂

    题链:http://lightoj.com/volume_showproblem.php?problem=1070 1070 - Algebraic Problem PDF (English) Sta ...

  2. LightOJ 1070 Algebraic Problem (推导+矩阵高速幂)

    题目链接:problem=1070">LightOJ 1070 Algebraic Problem 题意:已知a+b和ab的值求a^n+b^n.结果模2^64. 思路: 1.找递推式 ...

  3. HDU 2256 Problem of Precision(矩阵高速幂)

    题目地址:HDU 2256 思路: (sqrt(2)+sqrt(3))^2*n=(5+2*sqrt(6))^n; 这时要注意到(5+2*sqrt(6))^n总能够表示成an+bn*sqrt(6); a ...

  4. HDU - 5187 - zhx&#39;s contest (高速幂+高速乘)

    zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  5. HDU4869:Turn the pokers(费马小定理+高速幂)

    Problem Description During summer vacation,Alice stay at home for a long time, with nothing to do. S ...

  6. hdu 5187 高速幂高速乘法

    http://acm.hdu.edu.cn/showproblem.php?pid=5187 Problem Description As one of the most powerful brush ...

  7. [POJ 3150] Cellular Automaton (矩阵高速幂 + 矩阵乘法优化)

    Cellular Automaton Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 3048   Accepted: 12 ...

  8. NYOJ127 星际之门(一)(最小生成数的个数+高速幂)

    题目描写叙述: http://acm.nyist.net/JudgeOnline/problem.php?pid=127 能够证明.修建N-1条虫洞就能够把这N个星系连结起来. 如今.问题来了.皇帝想 ...

  9. HDOJ 4686 Arc of Dream 矩阵高速幂

    矩阵高速幂: 依据关系够建矩阵 , 高速幂解决. Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/ ...

  10. poj 2778 AC自己主动机 + 矩阵高速幂

    // poj 2778 AC自己主动机 + 矩阵高速幂 // // 题目链接: // // http://poj.org/problem?id=2778 // // 解题思路: // // 建立AC自 ...

随机推荐

  1. MFC_综述

    第一天(win消息机制.SDK编程基础)    1.基本概念介绍(SDK.API.句柄.消息队列.winmain函数)    2.第一个Windows界面程序(winAPI)    3.消息循环和窗口 ...

  2. zabbix user-defined item

    1.user-defind item at:/etc/zabbix/zabbix_agent.conf format: UserParameter=<key>,<command> ...

  3. JS第三方中间件的延伸

    js中间件 当我们在编写业务代码时候,我们无法避免有些业务逻辑复杂而导致业务代码写得又长又乱,如果再加上时间紧凑情况下写出来的代码估计会更让人抓狂.以至于我们一直在寻求更好的架构设计和更好的代码设计, ...

  4. pytorch系列 -- 9 pytorch nn.init 中实现的初始化函数 uniform, normal, const, Xavier, He initialization

    本文内容:1. Xavier 初始化2. nn.init 中各种初始化函数3. He 初始化 torch.init https://pytorch.org/docs/stable/nn.html#to ...

  5. 关闭Visual Studio 2015 关闭单击打开文件的功能

    工具-->选项-->环境-->选项卡和窗口-->预览选项卡 去掉“在解决方案资源管理器中预览选定的文件(在按住Alt的同时单击可避免预览)(X)”的勾选

  6. windows10下Anaconda的安装与tensorflow、opencv的安装与环境配置

    刚开始学习tensorflow和opencv这一块的知识,所以用博客这个平台来把自己这段学习的经历与感想写下来. tensorflow和opencv则用Anaconda来下载和配置环境. 下载Anac ...

  7. 条款31:将文件间的编译依存关系降至最低(Minimize compilation dependencies between files)

    NOTE1: 1.支持“编译依存性最小化”的一般构想是:相依于声明式,不要相依于定义式.基于此构想的两个手段是Handle classes 和 Interface classes. 2.程序库头文件应 ...

  8. 比特币 3角对冲python代码

    3角对冲原理 基础货币 base, 兑换货币 quote, 中间货币 mid. 市场分为3个市场 p3: base_quote p2: quote_mid p1: quote_mid 代码逻辑 1, ...

  9. Vue微信自定义分享时安卓系统config:ok,ios系统config:invalid signature签名错误,或者安卓和ios二次分享时均config:ok但是分享无效的解决办法

    简述需求:要求指定页面可以进行微信自定义分享(自定义标题,描述,图片,链接),剩下的页面隐藏所有基础接口.二次分享依然可以正常使用,切换至其他页面也可以正常进行自定义分享. 这两天在做微信自定义分享的 ...

  10. Laya Tween循环

    Laya Tween循环 @author ixenos 需求:做一个循环的缓动动画 方案: 1)如果只是线性变化,那么直接使用timer或者frameLoop来变化 2)如果需要有非线性变化,那么使用 ...