c++编程题
能打一下吗
老是超出时间限制
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float r, a, b;
int years = 0;
cin >> r >> a >> b;
float target = a + (a * r / 100); // 第一年的目标金额
while (target < b) {
a = target;
target = a + (a * r / 100); // 计算下一年的目标金额
years++;
}
cout << years << " " << fixed << setprecision(2) << target << endl;
return 0;
}