1.5 14: The problem of population growth

Description
There are currently x billion people in our country. At an annual growth rate of 0.1%, how many people will there be in n years?

Enter a
line containing two integers x and n, which are the population base and the number of years, separated by a single space.
Output
Output the final population, in 100 million units, to four decimal places. 1 <= x <= 100, 1 <= n <= 100.
Sample input
13 10
Sample output
13.1306

#include <iostream>
using namespace std;
int main()
{
    
    
	double x;
	int n;
	cin >>x>>n;
	for(int i=0;i<n;i++)
	{
    
    
		x = x*1.001;
	}
	printf("%.4lf", x);
	return 0;
}

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/111995054