給定 n 和 p,求 k^n=p 中的k

[心得]

1.使用double,所以印出來的時候要用%.0lf

 

#include <stdio.h>
#include <math.h>

int main()
{
    double n,p;
   
    while(scanf("%lf %lf",&n,&p)!=EOF)
    {
        printf("%.0lf\n",(double)pow(p,1/n));
    }
   
    return 0;
}

arrow
arrow
    全站熱搜

    RingsACM 發表在 痞客邦 留言(0) 人氣()