Bank interest

description

Farmer John in the last year to earn a lot of money! He wants to put the money for investment, and how much revenue they can get curious. APR investment compound known as R (an integer between 0 and 20). John M for the total value of existing money (an integer between 100 and 1,000,000). He knows they have to invest Y years (range 0-400). Please help him calculate how much money he will eventually, and it outputs the integer part. To ensure that the data within the 32-bit signed integer in the range of the output.

Input line contains three integers R, M, Y, separated by a single space between the adjacent two integers. Output An integer that is the ultimate owner John how much money (integer part). Sample input

5 5000 4

Sample Output

6077
 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 int main(){
 5     double r,m,y;
 6     int x;
 7     scanf("%lf%lf%lf",&r,&m,&y);
 8     r/=100;
 9     r+=1;
10     for(int i=1;i<=y;i++){
11         m*=r;
12     }
13     x=(int)m;
14     printf("%d",x);
15     return 0;
16 }

Tips: 复利 W = a * (1 + i) * ta

a: Principal; i: Rate; t: time

Guess you like

Origin www.cnblogs.com/bjt1015/p/11915477.html