網頁

2014年2月17日 星期一

UVa 113 Power of Cryptography

想法:
  在題目條件下,k^n與(k+1)^n的差異double的精度可以分辨的出來,因此直接對p開根號在四捨五入即可。


#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;
}

沒有留言:

張貼留言