P1163 银行贷款(1.26)

点击查看代码
#include<bits/stdc++.h>
using namespace std;

double w,k;
int m;

bool check(double x)
{
    double rest=w;
    for(int i=0;i<m;i++){
        rest=rest*(1+x)-k;
    }
    return rest>0;
}

int main()
{
    cin>>w>>k>>m;

    double l=0,r=3;

    for(int i=0;i<100;i++){
        double mid=(l+r)/2;
        if(check(mid)) r=mid;
        else l=mid;
    }

    printf("%.1lf",l*100);

    return 0;
    
}
posted @ 2026-01-26 22:48  AnoSky  阅读(0)  评论(0)    收藏  举报