坑点:
- 月利率可能大于1,二分范围要定在1~5
- 需要还的钱,随每个月的利息和还钱数变化
#include<iostream>
using namespace std;
double m, n;
int k;
int check(double v){
double sum = m;
for(int i = 0; i < k; i ++) sum = sum * (1 + v) - n;
if(sum >= 0) return 1;
return 0;
}
int main(){
cin >> m >> n >> k;
double l = 0, r = 5;
while(r - l >= 1e-4){
double mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
printf("%.1lf", l * 100);
return 0;
}