题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=2035

人见人爱A^B

Description

求A^B的最后三位数表示的整数。
说明:A^B的含义是“A的B次方”

Input

输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。

Output

对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。

Sample Input

2 3
12 6
6789 10000
0 0

Sample Output

8
984
1

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using std::map;
using std::min;
using std::find;
using std::pair;
using std::vector;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int M = 1000;
const int N = 100001;
const int INF = 0x3f3f3f3f;
void pow_mod(int A, int B) {
int ans = 1;
while(B) {
if(B & 1) ans = ans * A % M;
A = A * A % M;
B >>= 1;
}
printf("%d\n", ans);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int A, B;
while(~scanf("%d %d", &A, &B), A + B) {
pow_mod(A, B);
}
return 0;
}

hdu 2035 人见人爱A^B的更多相关文章

  1. HDU 2035 人见人爱A^B 分类: ACM 2015-06-22 23:54 9人阅读 评论(0) 收藏

    人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  2. HDU 2035.人见人爱A^B-快速幂

    人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  3. HDU 2035 人见人爱A^B(二分求幂,快速求幂)

    题意:求A的B次方的后三位数字 思路1:常规求幂,直接取余求解 代码: #include<iostream> #include<cstdio> using namespace ...

  4. 同余定理简单应用 - poj2769 - hdu 1021 - hdu 2035

    同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+ ...

  5. hdu 2034 人见人爱A-B

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目, ...

  6. 杭电 2035 人见人爱A^B【快速幂取模】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035 解题思路:这一题数据不大,可以用同余来做,也可以用快速幂来做 反思:定义成 #include&l ...

  7. hdu 2034人见人爱A-B

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034 解题思路:set的基本用法 #include<iostream> #include& ...

  8. HDU 2034 人见人爱A-B 分类: ACM 2015-06-23 23:42 9人阅读 评论(0) 收藏

    人见人爱A-B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  9. hdoj 2035 人见人爱A^B

    人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

随机推荐

  1. AD转换精度的计算

    声明原文来源于:http://wenku.baidu.com/view/1e6d8f3083c4bb4cf7ecd1c2.html 讨论AD转换分辨率的算法(zt) (1)在总长度为5米的范围里,平均 ...

  2. 安装python的redis模块

    wget --no-check-certificate https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz tar - ...

  3. 洛谷P1530 分数化小数 Fractions to Decimals

    P1530 分数化小数 Fractions to Decimals 103通过 348提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 题目 ...

  4. Java 动态编译组件 & 类动态加载

    1.JDK6 动态编译组件 Java SE 6 之后自身集成了运行时编译的组件:javax.tools,存放在 tools.jar 包里,可以实现 Java 源代码编译,帮助扩展静态应用程序.该包中提 ...

  5. 使用ngin的静态文件下载

    1,主配置文件nginx.xml #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error. ...

  6. ◆ 火狐浏览器去除JS方法:

    ◆ 火狐浏览器去除JS方法: 在火狐地址栏输入about:config   回车 在搜索地址栏中输入javascript.enabled 右键 当一行的中的,值由false变成trun,就OK了 . 

  7. verilog中符号位的扩展问题

    以下内容转自 艾米电子 - 使用有符号数,Verilog(http://www.cnblogs.com/yuphone/archive/2010/12/12/1903647.html) Verilog ...

  8. 苹果系列机型专业刷机,解锁,解ID

    如有软件开发需求,请留言或在猪八戒网主页留言http://home.zhubajie.com/8506525/,常年接收c.c++(vs2010.RAD studio xe5\RAD studio 2 ...

  9. Android knock code analysis

    My colleague she forgot the knock code and ask me for help. I know her phone is LG G3 D855 with Andr ...

  10. Cent OS 6 主机名设置

    1:查看主机名: #hostname 2:修改主机名: #vi /etc/sysconfig/network ETWORKING=yes HOSTNAME=superboy.com 3:重启生效: # ...