原题链接 POJ2109
题目大意:给你 n,p,求 np,1≤p≤10101,1≤n≤200,1≤np≤109
本蒟蒻先写了一个二分加快速幂加高精度的算法,但是一直 WA,然后查了一下 double 的范围是正负 10308 多,所以试了试 pow 直接开 n 次根号,然后成功WA了。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double n,p;
int get(){
printf("%.0lf\n",pow(p,1/n));
return 0;
}
int main(){
while(~scanf("%lf%lf",&n,&p))get();
return 0;
}
然后实在没办法,看看 cin 碰碰运气,然后就过了
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
double n,p;
int get(){
cout<<pow(p,1/n)<<endl;
return 0;
}
int main(){
while(cin>>n>>p)get();
return 0;
}
求大佬解释QWQ