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 ...
随机推荐
- plsql 无需配置客户端连接.
plsql 无需配置客户端连接. (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.5)(PORT=1521)))(C ...
- iOS应用崩溃日志分析 iOS应用崩溃日志揭秘
转自:http://www.raywenderlich.com/zh-hans/30818/ios%E5%BA%94%E7%94%A8%E5%B4%A9%E6%BA%83%E6%97%A5%E5%BF ...
- 项目Alpha冲刺(团队10/10)
项目Alpha冲刺(团队10/10) 团队名称: 云打印 作业要求: 项目Alpha冲刺(团队) 作业目标: 完成项目Alpha版本 团队队员 队员学号 队员姓名 个人博客地址 备注 22160041 ...
- CentOS笔记-系统概述
Linux系统的启动过程并不是大家想象中的那么复杂,其过程可以分为5个阶段: 内核的引导. 当计算机打开电源后,首先是BIOS开机自检,按照BIOS中设置的启动设备(通常是硬盘)来启动. 操作系统接管 ...
- Statelessness Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.
The server never relies on information from previous requests. Statelessness As per the REST (REpres ...
- MTK平台下Battery驱动分析
主要涉及代码: Kernel: kernel-3.10\drivers\power\mediatek\ kernel-3.10\drivers\misc\mediatek\mach\mt6580\&l ...
- STM32 DMA中断只进入一次的解决办法
问题解决参见:http://bbs.ednchina.com/BLOG_ARTICLE_3014819.HTM 经过我验证,这个说的是对的.
- HDU 6114 Chess 【组合数】(2017"百度之星"程序设计大赛 - 初赛(B))
Chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- eclipse4.3 解决没有check out as maven project
最近想工作之余写点测试demo,习惯了公司的开发环境,便决定自己搭建开发环境,首先是找到好用的eclipse,就是能够使用eclipse创建maven project工程,该工程能够被eclipse的 ...
- gitbash使用
gitbash是什么 git bash是Windows下的命令行工具. 基于msys GNU环境,有git分布式版本控制工具. 主要用于git版本控制,上传下载项目代码. GNU环境,就是说如果你喜欢 ...