Sicily 1394. Root of the Problem

来源:互联网 发布:fifaonline韩服数据库 编辑:程序博客网 时间:2024/05/16 11:29

答案就在ceil(pow(B,1/N))和floor(pow(B,1/N))这两者之间(很久没见过这么短的代码了)。

Run Time: 0sec

Run Memory: 312KB

Code length: 274Bytes

SubmitTime: 2012-02-09 17:07:48

// Problem#: 1394// Submission#: 1208419// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <iostream>#include <cmath>using namespace std;int main(){    int A, B, N;    while ( cin >> B >> N && B && N ) {        A = floor( powl( B, 1.0 / N ) );        cout << ( B - powl( A, N ) < powl( A + 1, N ) - B ? A: A + 1 ) << endl;    }    return 0;}                                 


 

原创粉丝点击