标签:水题
这道题就是大数阶乘的另类运用。
直接上代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[1005][1005];
int main()
{
int n, m, a[3], i, j; //数组开到3就是前三位
while(scanf("%d%d", &n, &m), n||m){
memset(a, 0, sizeof(a));
a[0] = 1; //初始化
for(i = 1; i <= m; i ++){
int c = 0;
for(j = 0; j < 3; j ++){
int s = a[j]*n+c;
a[j] = s%10;
c= s/10;
}
}
i = 2;
while(a[i] == 0&&i > 0) i --;//判断高位有没有无用的0
for(; i >= 0; i --)
printf("%d", a[i]);
printf("\n");
}
return 0;
} hdoj 2035 人见人爱A^B 【另类阶乘】,布布扣,bubuko.com
标签:水题
原文地址:http://blog.csdn.net/shengweisong/article/details/38370847