题解 | 买房子
买房子
https://www.nowcoder.com/practice/a4b46b53773e4a8db60b5f7629ce03e9
#include <iostream> using namespace std; int main() { int n; double k; int amount; double price; int count; while (cin >> n >> k) { count = 0; amount = 0; price = 200; while (count <= 21) { count++; //一年过去了 amount += n; if (count > 1) price *= (1 + k / 100); if (amount >= price) { cout << count << endl; break; } } if (count > 21) cout << "Impossible" << endl; } } // 64 位输出请用 printf("%lld")