#include <stdio.h>
int main() {
double principal = 1000000; // 元本(円)
double rate = 0.03; // 年利率(3%)
double target = 1500000; // 目標額(円)
double amount = principal; // 現在の元利合計
int years = 0; // 経過年数
// 元利合計が150万円を超えるまで計算
while (amount <= target) {
amount *= (1 + rate); // 複利計算
years++;
}
// 結果の表示
printf("元利合計が150万円を超える年数: %d年\n", years
); printf("元利合計: %.0f円\n", amount
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGRvdWJsZSBwcmluY2lwYWwgPSAxMDAwMDAwOyAvLyDlhYPmnKzvvIjlhobvvIkKICAgIGRvdWJsZSByYXRlID0gMC4wMzsgICAgICAgICAvLyDlubTliKnnjofvvIgzJe+8iQogICAgZG91YmxlIHRhcmdldCA9IDE1MDAwMDA7ICAgIC8vIOebruaomemhje+8iOWGhu+8iQogICAgZG91YmxlIGFtb3VudCA9IHByaW5jaXBhbDsgIC8vIOePvuWcqOOBruWFg+WIqeWQiOioiAogICAgaW50IHllYXJzID0gMDsgICAgICAgICAgICAgIC8vIOe1jOmBjuW5tOaVsAoKICAgIC8vIOWFg+WIqeWQiOioiOOBjDE1MOS4h+WGhuOCkui2heOBiOOCi+OBvuOBp+ioiOeulwogICAgd2hpbGUgKGFtb3VudCA8PSB0YXJnZXQpIHsKICAgICAgICBhbW91bnQgKj0gKDEgKyByYXRlKTsgLy8g6KSH5Yip6KiI566XCiAgICAgICAgeWVhcnMrKzsKICAgIH0KCiAgICAvLyDntZDmnpzjga7ooajnpLoKICAgIHByaW50Zigi5YWD5Yip5ZCI6KiI44GMMTUw5LiH5YaG44KS6LaF44GI44KL5bm05pWwOiAlZOW5tFxuIiwgeWVhcnMpOwogICAgcHJpbnRmKCLlhYPliKnlkIjoqIg6ICUuMGblhoZcbiIsIGFtb3VudCk7CgogICAgcmV0dXJuIDA7Cn0K