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。
来源


a的尾数为1~9 ,周期为 1,2,4;
所以可进行一下运算  a=a%10; b=b%4+4  (+4是因为要考虑当%4=0时的情况)
 #include<stdio.h>
#include<math.h>
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)==)
{
if(a==)
{
printf("0\n");
continue;
}
if(b==)
{
printf("1\n");
continue;
}
a=a%;
b=b%+;
printf("%d\n",(int)pow(a,b)%);
}
return ;
}

nyoj 473 A^B Problem的更多相关文章

  1. nyoj 623 A*B Problem II(矩阵)

    A*B Problem II 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 ACM的C++同学有好多作业要做,最头痛莫过于线性代数了,因为每次做到矩阵相乘的时候,大 ...

  2. nyoj 103 A + B problem II

    点击打开链接 A+B Problem II 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 I have a very simple problem for you. G ...

  3. NYoj The partial sum problem(简单深搜+优化)

    题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=927 代码: #include <stdio.h> #include & ...

  4. 每天一套题打卡|河南省第十一届ACM/ICPC

    A 计划日 题意:已知李明在YYYY年MM月DD日星期W订了学习计划,现在想看看李明N天后的完成情况和个人总结,你能告诉我那天的日期和星期几吗? 模拟日期计算: 计算星期可以用基姆拉尔森公式 //中国 ...

  5. NYOJ:题目524 A-B Problem

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多 ...

  6. Prime Ring Problem + nyoj 素数环 + Oil Deposits + Red and Black

    Prime Ring Problem Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) ...

  7. nyoj A+B Problem IV

    A+B Problem IV 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 acmj最近发现在使用计算器计算高精度的大数加法时很不方便,于是他想着能不能写个程序把这 ...

  8. A-B Problem nyoj

    A-B Problem 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 A+B问题早已经被大家所熟知了,是不是很无聊呢?现在大家来做一下A-B吧. 现在有两个实数A和 ...

  9. 【志银】NYOJ《题目524》A-B Problem

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多 ...

随机推荐

  1. python安装后推荐的安装两款文本编辑器

    Notepad++ 7.2.2和 Sublime Text --道心 Notepad++ 7.2.2 Notepad++ 是一款非常有特色的编辑器,是开源软件,可以免费使用.支持的语言: C, C++ ...

  2. MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL

    MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠 ...

  3. 安卓Android科大讯飞语音识别代码使用详解

    科大讯飞的语音识别功能用在安卓代码中,我把语音识别写成了Service,然后在Fragment直接调用service服务.科大讯飞语音识别用的是带对话框的那个,直接调用科大讯飞的语音接口,代码采用链表 ...

  4. 理解Docker(7):Docker 存储 - AUFS

    (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 (4)Docker 容器的隔离性 - 使用 ...

  5. github fork后的pull和保持同步

    前言 对github上的某个项目贡献自己的修改,但自己可能并没有那个仓库的权限,那要如何操作呢?git的机制和svn还是有些区别的,本文做些记录. 思路1 clone项目到本地,有修改之后,直接提交到 ...

  6. [LeetCode] Mini Parser 迷你解析器

    Given a nested list of integers represented as a string, implement a parser to deserialize it. Each ...

  7. C /C++ 语言练习册

    /************************************** 整数对应 32 bit 二进制数串中数字1的个数 2016-10-24 liukun ***************** ...

  8. StarUML license key

    参考博客:http://blog.csdn.net/Excing/article/details/48998891 方法 将StarUML/www/license/node/LicenseManage ...

  9. 微信小程序-关于重定向问题

    关于微信的重定向问题 wx.redirectTo(OBJECT) 参数 参数 类型 必填 说明 url 串 是 需要跳转的应用内页面的路径 成功 功能 否 接口调用成功的回调函数 失败 功能 否 接口 ...

  10. [CI] 使用Jenkins自动编译部署web应用

    写在前面 初步接触持续集成自动化过程,本篇主要介绍基于Jenkins实现持续集成的方式,通过案例介绍线上自动编译及部署的配置过程 持续集成 持续集成是一种软件开发实践,即团队开发成员经常集成它们的工作 ...