0分求助:哪里错了?
查看原帖
0分求助:哪里错了?
1382733
VictorZhou楼主2025/7/24 18:35
#include<bits/stdc++.h>
using namespace std;
double s,a;
int t;
bool check(double x){
    double ts=s;
    for(int i=1;i<=t;i++){
        ts=ts*(x+1)-a;
    }
    if(ts>0){
        return false;
    }
    return true;
}
int main(){
    cin>>s>>a>>t;
    double st=0.001,ed=1,mid;
    while(ed-st>0.001){
        mid=(st+ed)/2;
        if(check(mid)){
            st=mid+0.001;
        }else{
            ed=mid-0.001;
        }
    }
    printf("%.1lf\n",st*100);
    return 0;
}

劳各位大佬解答,解答必关!

2025/7/24 18:35
加载中...