题解 | 买房子
买房子
https://www.nowcoder.com/practice/a4b46b53773e4a8db60b5f7629ce03e9
#include <iostream>
using namespace std;
int main() {
double n,k;
while (cin >> n >> k) { // 注意 while 处理多个 case
double cash=n;
double house=200;
for(int i=2;i<=20;i++)
{house=house*(1+k/100);
cash+=n;
if(cash>=house)
{cout<<i<<endl;
break;
}
}if(cash<house)
cout<<"Impossible"<<endl;
}
}
// 64 位输出请用 printf("%lld")
查看23道真题和解析