~题目链接~
http://poj.org/problem?id=2109
输入
2 16 3 27 7 4357186184021382204544
结果
4 3 1234
kn = p,一直k和p,求n。
做完这道题,让我知道了math.h 的强大
1.exp+log
#include<cstdio>
#include<cstdlib>
#include<cmath>
int main()
{
double n,m;
while(~scanf("%lf%lf",&n,&m))
printf("%.0f\n",exp(log(m)/n));//exp(计算指数,用来计算以e为底的x次方值,即ex值,然后将结果返回)
//log(计算以e为底的对数值)
return 0;
}
2.pow
#include<cstdio>
#include<cmath>
int main()
{
double n,m;
while(~scanf("%lf%lf",&n,&m))
printf("%.0f\n",pow(m,1/n));//pow(用来计算以x为底的y次方值,即xy值,然后将结果返回)
return 0;
}
附带俩math的网址
http://hi.baidu.com/zsb517/item/ec2f99d2414e9514d90e4410
http://zh.wikipedia.org/zh/Math.h