标签:进制 51nod 内容 NPU ace amp printf time sample
一个数N(1 <= N <= 10^9)
输出N^N的末位数字
13
3
快速幂
代码:
#include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; int n; int main() { scanf("%d",&n); int d = 1,e = n % 10; while(n) { if(n % 2) d = (d * e) % 10; e = (e * e) % 10; n /= 2; } printf("%d",d); return 0; }
标签:进制 51nod 内容 NPU ace amp printf time sample
原文地址:https://www.cnblogs.com/8023spz/p/10884204.html