#include <cmath> #include <iomanip> #include <iostream> using namespace std; // 函数用于计算 log_a(x) double log_base(double x, double base) { return std::log(x) / std::log(base); } // 函数用于计算 f(x) 的二阶导数 f''(x) = -1/(x^2 * ln(a)) double f_double_prime(double x, double a) { return -1.0 / (x * x * std::log(a)); } // 函数用于计算 f(x) = log_a(x) - bx double f(double x, double a, double b) { return log_base(x, a) - b * x; } int main() { int a, b; cin >> a >> b; if ((2 <= a && a <= 1000) && (1 <= b && b <= 1000)) { // 计算临界点 x double critical_point = 1.0 / (b * std::log(a)); // 检查临界点是否在定义域内 if (critical_point <= 0) { std::cerr << "Critical point is not in the domain (x > 0)" << std::endl; return 1; } // // 计算二阶导数以确认是最大值 double second_derivative = f_double_prime(critical_point, a); if (second_derivative >= 0) { std::cerr << "Critical point is not a maximum" << std::endl; return 1; } // 计算最大值 double max_value = f(critical_point, a, b); // 设置输出格式为固定小数点后五位 std::cout << std::fixed << std::setprecision(10); std::cout << max_value << std::endl; } } // 64 位输出请用 printf("%lld")