Advertisement
MonsterScripter

CodinGame_2023_08_22__18_31_00__amount.c

Aug 22nd, 2023 (edited)
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5.  
  6. int main()
  7. {
  8.     float money_now;
  9.     scanf("%f", &money_now);
  10.     float annual_rate_of_return;
  11.     scanf("%f", &annual_rate_of_return);
  12.     float annual_genie_money;
  13.     scanf("%f", &annual_genie_money);
  14.     int your_age;
  15.     scanf("%d", &your_age);
  16.  
  17.     float target_balance = 1000000.0;
  18.     float current_balance = money_now;
  19.     int age = your_age;
  20.     while (current_balance < target_balance) {
  21.         current_balance += annual_genie_money;
  22.         current_balance *= (1 + annual_rate_of_return / 100);
  23.         age++;
  24.     }
  25.     printf("%d\n", age);
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement