1117 Demographic Issues

Title description

In 1980, the world population reached 4.5 billion, calculated at an annual growth rate of 1%. When did the world population exceed N billion. (N is a number greater than 4.5 billion)

Input requirements

Enter a real number N, the unit is 100 million. If you enter the number 46.2, it means 4.62 billion.

Output requirements

Output the value of the corresponding year. Year value integer.

Input sample

45.95

Sample output

1983

prompt

It is recommended to use double

Reference program

#include<stdio.h>

int main()
{
    double x,y=45.0;
    int i;

    scanf("%lf",&x);
    for(i=0;y<=x;i++)
    {
        y = y * (1+0.01);
    }
    printf("%d\n",1980+i);
}

 

Guess you like

Origin blog.csdn.net/weixin_44643510/article/details/113932012