hdoj1097
好久没有遇到过这样的题,似乎记得以前完全就是靠规律啊什么的。。。。
然后刚刚看到,这不就是快速幂取膜就好了嘛…
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define LL __int64
#define N 2010
int quickmul(int g,int a)
{
int ans=1;
a%=10;
while(g)
{
if(g%2==1)
{
ans=ans*a%10;
}
a=a*a%10;
g/=2;
}
return ans%10;
}
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
int ans;
ans=quickmul(m,n);
printf("%d\n",ans%10);
}
return 0;
}
hdoj1097的更多相关文章
- HDOJ 1061 Rightmost Digit(循环问题)
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...
随机推荐
- sort-list——链表、快慢指针找中间、归并排序
Sort a linked list in O(n log n) time using constant space complexity. 链表,快慢指针找中点,归并排序. 注意判断条件fast-& ...
- U盘 文件被隐藏解决办法
原地址:http://www.deyi.com/thread-351635-1-1.html 方法:运行cmd( 在任意目录都行)单个文件 :attrib c:\"要修改的文件夹名字&quo ...
- HDU 1028 Ignatius and the Princess III (母函数或者dp,找规律,)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- iOS_40_核心动画
核心动画之CATransition转场动画 终于效果图: 核心动画之CAKeyFrameAnimation,图标抖动效果 终于效果图: 核心动画之CAAnimationGroup(动画组) 终于效果图 ...
- 【Web前端】清除浮动&css中文字体
清理浮动有非常多种方式,像使用 br 标签自带的 clear 属,使用元素的 overflow.使用空标签来设置 clear:both 等等.但考虑到兼容问题和语义化的问题,一般我们都会使用例如以下代 ...
- 基于node+koa2+mongodb实现简单的导航管理系统
基于node+koa2+mongodb实现简单的导航管理系统 项目说明 本项目gitbub地址 https://github.com/xuess/nav-admin,喜欢请star 基于node 实现 ...
- Storm项目:流数据监控1《设计文档…
博客公告: (1)本博客全部博客文章搬迁至<博客虫>http://blogchong.com/ (2)文章相应的源代码下载链接參考博客虫站点首页的"代码GIT". (3 ...
- XHTML中button加入超链接以及使插入图片与屏幕一样大
1.button加入超链接 (1)假设是在本页跳转到新页面.用 <span style="font-size:18px;"><input type="b ...
- Comparing Random and Sequential Access in Disk and Memory
The Pathologies of Big Data - ACM Queue https://queue.acm.org/detail.cfm?id=1563874
- redis02---对于key的操作命令
Redis对于key的操作命令 del key1 key2 ... Keyn 作用: 删除1个或多个键 返回值: 不存在的key忽略掉,返回真正删除的key的数量 rename key newkey ...