#include <iostream>
using namespace std;
int main() {
// (1)
// input: balance, r, holding_years
// output: balance for each year
int balance = 100, r = 10, holding_years = 10;
for (int i = 1; i <= holding_years; i++) {
balance *= (1 + r / 100.0);
cout << i << ": " << balance << endl;
}
// (2)
// input: balance, r, goal
// output: holding_years
balance = 100;
r = 10;
int goal = 200;
int n = 0;
while (balance < goal) {
balance *= (1 + r / 100.0);
n++;
}
cout << "Holding years = " << n << endl;
cout << "Balance = " << balance << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkKCS8vICgxKQoJLy8gICAgIGlucHV0OiBiYWxhbmNlLCByLCBob2xkaW5nX3llYXJzCgkvLyAgICAgb3V0cHV0OiBiYWxhbmNlIGZvciBlYWNoIHllYXIKCWludCBiYWxhbmNlID0gMTAwLCByID0gMTAsIGhvbGRpbmdfeWVhcnMgPSAxMDsKCWZvciAoaW50IGkgPSAxOyBpIDw9IGhvbGRpbmdfeWVhcnM7IGkrKykgewoJCWJhbGFuY2UgKj0gKDEgKyByIC8gMTAwLjApOwoJCWNvdXQgPDwgaSA8PCAiOiAiIDw8IGJhbGFuY2UgPDwgZW5kbDsKCX0KICAgIAogICAgLy8gKDIpCgkvLyAgICAgaW5wdXQ6IGJhbGFuY2UsIHIsIGdvYWwKCS8vICAgICBvdXRwdXQ6IGhvbGRpbmdfeWVhcnMKCWJhbGFuY2UgPSAxMDA7CglyID0gMTA7CglpbnQgZ29hbCA9IDIwMDsKIAoJaW50IG4gPSAwOwoJd2hpbGUgKGJhbGFuY2UgPCBnb2FsKSB7CgkJYmFsYW5jZSAqPSAoMSArIHIgLyAxMDAuMCk7CgkJbisrOwoJfQoJY291dCA8PCAiSG9sZGluZyB5ZWFycyA9ICIgPDwgbiA8PCBlbmRsOwoJY291dCA8PCAiQmFsYW5jZSA9ICIgPDwgYmFsYW5jZSA8PCBlbmRsOwogCglyZXR1cm4gMDsKfQk=