快速计算数a开b次平方根的值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/L1558198727/article/details/85091434

就是sqrt(sqrt(sqrt(……)))一共b个sqrt吧。

等价变换

a 1 2 b = e l n ( a ) 2 b a^{\frac{1}{2^b}}=e^{\frac{ln(a)}{2^b}}

e 取15位 双精度最大值

2.718281828459045
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    int a,b;
    double ret;
    scanf("%d%d",&a,&b);
    ret = (double)a;
    ret = log(ret)/(pow(2,b));
    ret = pow(2.718281828459045,ret);
    printf("%.2f\n",ret);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/L1558198727/article/details/85091434
今日推荐