HDU1061 - Rightmost Digit (二分幂取模)
来源:互联网 发布:英语口语app软件 编辑:程序博客网 时间:2024/05/22 14:51
题目链接
- 思路
- 代码
思路
需要取出
二分幂取模实际上就是利用分治的思想。
代码
#include <cstdio>#include <cmath>using namespace std;int pow_mod(int a, int b, int mod){ if(b==0) return 1; int ans = pow_mod(a, b>>1, mod); ans = ans * ans % mod; // 此处可能溢出,也可直接用 long long if(b&1) ans = ans * (a % mod) % mod; return ans;}int main(){ int num, t; scanf("%d", &t); while(t--) { scanf("%d", &num); printf("%d\n", pow_mod(num, num, 10)); } return 0;}
0 0
- HDU1061 - Rightmost Digit (二分幂取模)
- Rightmost Digit(HDU1061)
- Rightmost Digit(hdu1061)
- HDU1061-Rightmost Digit(快速幂取模)
- HDU1061:Rightmost Digit(快速幂取模)
- HDU1061-Rightmost Digit(快速幂取模)
- HDU1061 Rightmost Digit(快速幂取模)
- 【快速幂取模】HDU1061 Rightmost Digit
- Rightmost Digit(hdu1061二分取模)
- (解题报告)HDU1061---Rightmost Digit
- hdu1061 rightmost digit(C语言)
- HDU1061:Rightmost Digit
- HDU1061 Rightmost Digit
- hdu1061 Rightmost Digit
- HDU1061 Rightmost Digit
- HDU1061 Rightmost Digit
- hdu1061 Rightmost Digit
- hdu1061 rightmost digit
- OAuth 2.0
- allwinner A10平台下的ar6302驱动移植
- IOS 手势UIPinchGestureRecognizer(缩放手势) UIRotationGestureRecognizer(旋转手势)
- RowDataBound事件
- Matlab psf2otf与fft2函数的关系
- HDU1061 - Rightmost Digit (二分幂取模)
- 这段时间遇到的技术点总结
- #include <afx.h>头文件的作用
- EditText focusable editable enable
- POJ 2486 Apple Tree
- Customizing AIX Prompt
- Android 项目中各种小技巧
- A qualitative overview of x264's ratecontrol methods
- 算法系列(一) Google方程式