some programs!!
This commit is contained in:
1 parent
ed054247d5
commit
71f1022dea
38 files changed
+1037
-281
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
||||
Reference in new issue
Block a user