HDU1163 快速幂+九余数
来源:互联网 发布:c 常量数组 编辑:程序博客网 时间:2024/06/01 08:52
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1163
输入n,求n的n次方的九余数。
思路:将快速幂和九余数定理结合一下。
#include<iostream>#include<cmath>using namespace std;int mode_xp(int a, int b, int n){ long long ret = 1, temp; temp = a; while (b) { if (b & 1) ret = ret*temp%n; temp = temp*temp%n; b >>= 1; } return ret;}int main(){ int n,ans; while (cin >> n&&n!=0) { ans = mode_xp(n, n, 9); if (ans == 0) ans = 9; cout << ans << endl; } return 0;}
阅读全文
0 0
- HDU1163 快速幂+九余数
- HDU1163 Eddy's digital Roots(快速幂+九余数定理)
- HDU1163九余数定理
- HDU1163 Eddy's digital Roots(解法二)【快速模幂+九余数定理】
- HDU1163【九余数定理】【水题】
- HDU1163 Eddy's digital Roots【九余数定理】
- Hdu1163 Eddy's digitai Roots(九余数定理)
- hdu 1163 Eddy's digital Roots(九余数定理,快速幂)
- HDU 1163 Eddy's digital Roots(九余数定理+快速幂)
- 快速幂定理和九余数定理(Eddy's digital Roots)
- hdu1163
- hdu1163
- hdu1163
- hdu1163
- HDU1163
- hdu1163
- HDU1163
- 九余数定理
- DATAGURAD BROKER 初探
- 虚拟网卡抓包方案
- 实现夜间模式切换
- java 中使用继承与组合的区别与使用场合
- mysql默认安装目录说明
- HDU1163 快速幂+九余数
- 《半小时漫画中国史》读书笔记
- listview多条目
- 栈和队列——生成窗口最大值数组
- CSS样式之复合选择器
- SPOJ 1557 GSS2 线段树
- 字符串数组的相互转换
- Mac下python路径
- tomcat管理界面登录无法进入