題解 | #小紅的函數(shù)最大值#
2025/5/14
代碼如下
#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
double x = 0;
int a ,b;
cin>>a>>b;
x=1/(b*log(a));
cout<<fixed;
cout<<setprecision(10)<<log(x)/log(a) - b*x <<endl;
}
// 64 位輸出請(qǐng)用 printf("%lld")
需要注意的是本題對(duì)精度有要求,所以需要使用iomanip頭文件,setprecision(n)其中n就是輸出的小數(shù)點(diǎn)后幾位。
果在日常刷題打卡 文章被收錄于專欄
日常的打卡記錄