题解 | #买房子#
买房子
https://www.nowcoder.com/practice/a4b46b53773e4a8db60b5f7629ce03e9
#include <iostream> #include<math.h> using namespace std; int main() { int N, SumN; float K, SumK; // 注意 while 处理多个 case while (cin >> N >> K) { for (int i = 1;; i++) { bool Flag = false; SumN = N * i; SumK = 200 * pow((1 + K / 100), i - 1); //cout << SumN << " " << SumK << endl; if (SumN > SumK) { cout << i<<endl; Flag = true; break; return 0; } if ((SumK - SumN) > (200 - N)) { cout << "Impossible" << endl; break; return 0; }; } } } // 64 位输出请用 printf("%lld")