poj 3100(水题,注意pow()参数不能为Int,int)
作者:互联网
#include<iostream> #include<cmath> using namespace std; int main(){ int b,n,result,i,minj,minx,tmp; while(scanf("%d%d",&b,&n)==2&&b){ minx = 1000005; for(i=1;;i++){ tmp = pow((double)i,n); if(tmp<b){ if(b-tmp<minx){ minx = b-tmp; minj = i; } } else if(tmp==b){ minx = 0; minj = i; break; } else if(tmp>b){ if(tmp-b<minx){ minx = tmp-b; minj = i; } break; } } printf("%d\n",minj); } return 0; }
标签:tmp,minj,水题,Int,pow,minx,int,include 来源: https://www.cnblogs.com/stevenzrx/p/15620919.html