總結:求冪次,就是log(b) / log(a),b是結果,a是底數。
二分的時候注意終止條件是l < r
int k, m;
inline double cal(long long x){
return sqrt(double(x)) + int((log(x) / log(k))) - m;
}
void solve(){
cin >> k >> m;
long long l = 1, r = 1e9;
while (l < r){
long long mid = (l + r) >> 1;
if (cal(mid) > 0){
r = mid;
}
else{
l = mid + 1;
}
}
cout << l << '\n';
}