好久没有遇到过这样的题,似乎记得以前完全就是靠规律啊什么的。。。。

然后刚刚看到,这不就是快速幂取膜就好了嘛…

#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的更多相关文章

  1. HDOJ 1061 Rightmost Digit(循环问题)

    Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...

随机推荐

  1. 浅谈BloomFilter【下】用Java实现BloomFilter

    通过前一篇文章的学习,对于 BloomFilter 的概念和原理.以及误报率等计算方法都一个理性的认识了. 在这里,我们将用 Java'实现一个简单的 BloomFilter . package pr ...

  2. CSS3 animation(动画) 属性

    一.animation 1.CSS3 animation(动画) 属性 语法: animation: name duration timing-function delay iteration-cou ...

  3. Printing multipage output

    Printing known-length multipage output Using the PrintDataGrid control for multipage grids Example: ...

  4. mysql 存储过程(支持事务管理)

    CREATE DEFINER=`root`@`localhost` PROCEDURE `createBusiness`(parameter1 int) BEGIN #Routine body goe ...

  5. XMLHTTPRequest DEMO(发送测试)

    对于其中的HTTP状态,我们知道200-299表明访问成功:300-399表明需要客户端 反应来满足请求:400-499和500-599表明客户端和服务器出错:其中常用的如404表示资源没找到,403 ...

  6. WebSocket 和 Socket 的区别

    WebSocket 和 Socket 的区别   英文:TheAlchemist 链接:http://www.jianshu.com/p/59b5594ffbb0 <刨根问底 HTTP 和 We ...

  7. 利用PHP判断iPhone、iPad、Android、PC设备

    首页那张大图确实是一个比较头疼的问题 在PC上显示是没问题的,可是到手机上就会超出页面一大截,如果做自适应,图片会被强制压缩 无奈只能用wp_is_mobile()函数在手机上隐藏了这张图,可是这函数 ...

  8. Springboot读取自定义的yml文件中的List对象

    Yml文件(novellist.xml)如下: novellist:   list:     - name: 笑傲江湖       type: 武侠       master: 令狐冲       a ...

  9. php网站前台utf-8格式有时会出现莫名其妙的空白行,重新保存下编码格式就可以了

    php网站前台utf-8格式有时会出现莫名其妙的空白行,重新保存下编码格式就可以了.

  10. php composer 相关及版本约束等小技巧

    对于现代语言而言,包管理器基本上是标配.Java有Maven,Python有pip,Ruby有gem,Nodejs有npm.PHP的则是PEAR,不过PEAR坑不少: 依赖处理容易出问题 配置非常复杂 ...