题解 | 买房子
买房子
https://www.nowcoder.com/practice/a4b46b53773e4a8db60b5f7629ce03e9
#include <iostream>
using namespace std;
int main() {
int n;
double k;
while (cin >> n >> k) {
int price = 200;
int salary = 0;
bool afford = false;
for (int i = 1; i <= 21; i++) {
salary += n;
if (salary >= price) {
afford = true;
cout << i << endl;
break;
}
price = 1.0 * price * (1+ k / 100);
}
if (!afford)cout << "Impossible" << endl;
}
}
// 64 位输出请用 printf("%lld")
查看7道真题和解析