博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将一个数开m次方(模板)
阅读量:241 次
发布时间:2019-02-28

本文共 418 字,大约阅读时间需要 1 分钟。

#include 
#include
#include
#include
#include
using namespace std;int fun(int n){ int ans = 0; while(n){ n /= 2; ans++; } return ans;}int main(){ int n; //将n开m次根 int m = 3; scanf("%d",&n); int k = fun(n);//n的二进制位 int now = n >> ((k-1)*(m-1)/m),last; do{ last = now; now = (last*(m-1)+n/(pow(last,m-1)))/m; }while(now < last); printf("%d\n",last); return 0 ;}

转载地址:http://enqp.baihongyu.com/

你可能感兴趣的文章