在題目條件下,k^n與(k+1)^n的差異double的精度可以分辨的出來,因此直接對p開根號在四捨五入即可。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cmath> | |
using namespace std; | |
int main() | |
{ | |
double n,p; | |
while (scanf("%lf %lf", &n, &p) != EOF) | |
printf("%.0f\n",pow(p,1.0/n)); | |
return 0; | |
} |
沒有留言:
張貼留言