http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=49
題意:
輸入n和p,得出“以p爲底,開n次方”。
解題:
直接使用cmath的pow,由於數字很大,注意用double,再轉換成int。
水題快樂~
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
// #define LOCAL_TEST
int main()
{
#ifdef LOCAL_TEST
freopen("f:\\in.txt", "r", stdin);
freopen("f:\\out.txt", "w+", stdout);
#endif
double n;
double p;
while ( cin >>n >>p )
{
cout <<(int)(pow(p, 1.0 / n)+0.5) <<'\n';
} // end while
return 0;
}