快速幂暴力
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #define ll long long using namespace std; double pow(double a,int b){ double ans=1; while(b){ if(b&1){ ans=ans*a; } a=a*a; while(a<0.01)a*=10; b>>=1; } return ans; } int main() { int n; while(~scanf("%d",&n)){ double t=n; while(t>=1)t/=10; double ans=pow(t,n); while(ans<1)ans*=10; printf("%dn",(int)ans); } return 0; } ---来自腾讯云社区的---饶文津【ZOJ2277】The Gate to Freedom---饶文津
题意题解代码#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int main() {
while(~scanf("%d",&n))
printf("%dn",(int)pow(10,n*log10(n)-(int)(n*log10(n))));
return 0;
}

微信扫一扫打赏
支付宝扫一扫打赏