ZOJ Problem Set

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1818

一开始想着用循环做,看了别人的解法才发现根本没必要,比较根号n就行了

 1 #include<iostream>
 2 #include<cmath>
 3 #include<iomanip>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8           double m,n;
 9           while(cin>>m>>n)
10           {
11                     if(m==0 || n == 0)
12                               break;
13                     int a = (int)powf(m,1/n);
14                     if(m-powf(a,n)<powf(a+1,n)-m)
15                               cout<<a<<endl;
16                     else
17                               cout<<a+1<<endl;
18           }
19 }
原文地址:https://www.cnblogs.com/qlky/p/4963470.html