wa on #3 求助
查看原帖
wa on #3 求助
782768
Mierstan085楼主2023/11/24 17:11
#include <bits/stdc++.h>
#define db double
using namespace std;

int w0, w, m;
bool check(db x){
    db w1 = 1, tot = 0;
    for (int i = 0; i < m; i ++) w1 /= 1 + x,tot += w1;
    return tot > w0 / 1.0 / w;
}

int main(){
    cin >> w0 >> w >> m;
    db p = -1e-9, k = 1e-9; 
    while (k > 1e-11){
        if(check(p + k)) p += k, k *= 2.0; 
        else k /= 2.0;
    }
    printf("%.1lf", p * 100.0);
}
2023/11/24 17:11
加载中...