您的位置:首页 > 其它

UVA 113 - Power of Cryptography(二分)

2012-07-14 15:06 405 查看
题目链接

被数据给吓到了,本来以为是各种高精度的综合题,又想是否是高深的数学结论题,怎么做出来的人这么多啊。。。看reader的时候同学的BOLG有,发现原来是double 就可以搞,无语。。。。连精度都不卡。。。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define N 1000000000
int main()
{
int n;
double p,s,str,end;
while(scanf("%d%lf",&n,&p)!=EOF)
{
str = 1;
end = N;
while(str < end)
{
s = pow((str+end)/2,n);
if(s < p)
{
str = (str+end)/2;
}
else if(s == p)
{
break;
}
else
{
end = (str+end)/2;
}
}
printf("%.0lf\n",str);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: