27 lines
628 B
C++
27 lines
628 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
int afford_year(double salary, double price, int current_year = 1, double current_money = 0) {
|
|
if ((current_money += salary) >= price) { return current_year; }
|
|
if (current_year > 100) { return -1; }
|
|
return afford_year(salary * 1.08, price * 1.10, current_year + 1, current_money);
|
|
}
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(false);
|
|
cin.tie(nullptr);
|
|
|
|
double money, price;
|
|
int ans;
|
|
cin >> money >> price;
|
|
|
|
if ((ans = afford_year(money, price)) == -1) {
|
|
cout << "Forget it." << endl;
|
|
} else {
|
|
cout << ans << endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|