HDU1061 Rightmost Digit
2013-04-04 18:57
417 查看
题意:
求N^N的最右位数字
快速幂解决
求N^N的最右位数字
快速幂解决
#include<cstdio> #include<algorithm> using namespace std; int main() { int total; scanf("%d",&total); while(total--) { int n; scanf("%d",&n); int m=n;//n^m int ans=1; n%=10; while(m) { if(m&1)//m为奇数 { ans*=n; ans%=10; } m>>=1; n*=n; n%=10; } printf("%d\n",ans%10); } return 0; }
相关文章推荐
- hdu 1061 Rightmost Digit
- hdu 1061 Rightmost Digit
- hdu 1061 Rightmost Digit
- HDU 1061 The rightmost digit
- HDU 1061 Rightmost Digit
- hdu 1061 Rightmost Digit_快速幂取余
- hdu 1061 Rightmost Digit
- 算法模板之快速幂取模(HDU1061 Rightmost Digit)
- HDU 1061 Rightmost Digit
- HDU 1061 Rightmost Digit
- hdu 1061 Rightmost Digit
- hdu1061 Rightmost Digit
- HDU - 1061 Rightmost Digit
- hdu 1061 - Rightmost Digit(求N^N末位)
- HDU 1061 Rightmost Digit
- HDU - 1061 Rightmost Digit(数学)
- HDU 1061 Rightmost Digit
- hdu rightmost digit 1061
- HDU-1061-Rightmost Digit,快速幂水过!~~
- hdu 1061 Rightmost Digit(水题,打表)