题目连接

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. port-channel和channel-group

    cisco交换机上的链路聚合 2层 ethernet channel (interface)#channel-group number mode {on | auto [no-silent]|desi ...

  2. 【程序与资源】linux程序与资源管理

    程序与资源管理:ps.top.free.sar.kill.uname ①ps语法: [root @test /root ]# ps -aux 参数说明: a   :选择所有的程序列出 u   :所有使 ...

  3. js获取服务器控件DropDownList所选中的各项属性

    var ddl = document.getElementById("DropDownList1"); alert(ddl.selectedIndex);//选择索引值 alert ...

  4. pip的安装及使用

    pip 是“A tool for installing and managing Python packages.”,即pip是python的软件安装工具安装:方法一:(亲自使用)1.去官网下载get ...

  5. BZOJ3613 南园满地堆轻絮-二分法

    http://www.lydsy.com/JudgeOnline/problem.php?id=3613 //话说BZOJ终于修好了... Description 小 Z 是 ZRP(Zombies' ...

  6. Hot OS'15 summary

    My OS Ought to Know Me Better: In-app Behavioural Analytics as an OS Service   Earlence Fernandes, U ...

  7. hive安装(一)

    1.解压 [root@cluster3 hadoop]# tar -zxvf apache-hive--bin.tar.gz 2.修改环境变量 export HIVE_HOME=/usr/local/ ...

  8. openstack实例热迁移

    [DEFAULT]scheduler_default_filters=AllHostsFilterallow_resize_to_same_host=Trueallow_migrate_to_same ...

  9. Artifacts Gallery - Seahorse Collector, The

    Artifacts Gallery - Seahorse Collector, The

  10. javaSE第三天

    第三天    12 1:运算符(掌握)    12 (1)算术运算符    12 (2)赋值运算符    12 (3)比较运算符    13 (4)逻辑运算符    13 (5)位运算符(了解)    ...