nyoj 473 A^B Problem
A^B Problem
- 描述
- 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的更多相关文章
- nyoj 623 A*B Problem II(矩阵)
A*B Problem II 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 ACM的C++同学有好多作业要做,最头痛莫过于线性代数了,因为每次做到矩阵相乘的时候,大 ...
- nyoj 103 A + B problem II
点击打开链接 A+B Problem II 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 I have a very simple problem for you. G ...
- NYoj The partial sum problem(简单深搜+优化)
题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=927 代码: #include <stdio.h> #include & ...
- 每天一套题打卡|河南省第十一届ACM/ICPC
A 计划日 题意:已知李明在YYYY年MM月DD日星期W订了学习计划,现在想看看李明N天后的完成情况和个人总结,你能告诉我那天的日期和星期几吗? 模拟日期计算: 计算星期可以用基姆拉尔森公式 //中国 ...
- NYOJ:题目524 A-B Problem
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多 ...
- Prime Ring Problem + nyoj 素数环 + Oil Deposits + Red and Black
Prime Ring Problem Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) ...
- nyoj A+B Problem IV
A+B Problem IV 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 acmj最近发现在使用计算器计算高精度的大数加法时很不方便,于是他想着能不能写个程序把这 ...
- A-B Problem nyoj
A-B Problem 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 A+B问题早已经被大家所熟知了,是不是很无聊呢?现在大家来做一下A-B吧. 现在有两个实数A和 ...
- 【志银】NYOJ《题目524》A-B Problem
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多 ...
随机推荐
- kettle中参数和变量的区别
图一: 图二: 何时使用'?'何事使用${}应当根据情况: 在图二中使用的是${}因为此时没有"作为参数的字段",所以只能用el表达式直接获取其值,在图一中有"作为参数的 ...
- 数组,集合分割函数,join()
join函数定义如下: // 串联类型为 System.String 的 System.Collections.Generic.IEnumerable<T> 构造集合的成员,其中在每个成员 ...
- jquery.mobiscroll仿Iphone ActionSheet省市区联动
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="u ...
- 1877: [SDOI2009]晨跑
1877: [SDOI2009]晨跑 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 2007 Solved: 1085[Submit][Status][ ...
- 解读ASP.NET 5 & MVC6系列(15):MvcOptions配置
程序模型处理 IApplicationModelConvention 在MvcOptions的实例对象上,有一个ApplicationModelConventions属性(类型是:List<IA ...
- [LeetCode] Product of Array Except Self 除本身之外的数组之积
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...
- Nginx 安装以及反向代理配置(windows)
安装 windows 下 Nginx 安装非常简单,下载地址 http://nginx.org/en/download.html. 选择红框这个,下载下来是个 zip 文件,解压.这时我们双击根目录的 ...
- go 常用包
标准的 Go 代码库中包含了大量的包,并且在安装 Go 的时候多数会伴随一起安 装.浏览 $GOROOT/src/pkg 目录并且查看那些包会非常有启发. fmt:包 fmt 实现了格式化的 I/O ...
- Redis中connect与pconnect区别?
1.首先先介绍下connect和pconnect的区别. connect:脚本结束之后连接就释放了. 2.pconnect:脚本结束之后连接不释放,连接保持在php-fpm进程中. 所以使用pconn ...
- jquery获取url参数及url加参数的方法
转--http://www.jb51.net/article/73896.htm <script src="js/jquery-1.7.2.min.js" type=&quo ...