Earth population carrying capacity estimation analysis and C++ code

Description

Assume that the nascent resources on Earth grow at a constant rate. According to this calculation, the existing resources on the earth plus new resources can support x billion people to live for a year, or y billion people to live for b years. In order to achieve sustainable development and avoid resource depletion, how many billions of people can the earth support at most?

Input

One line, including four positive integers x, a, y, b, separated by a single space

Output

A real number, indicating that the earth can support hundreds of millions of people at most, with two decimal places.

Sample Input 1 

110 90 90 210

Sample Output 1

75.00

Sample Input 2 

65 200 120 50

Sample Output 2

46.67

Hint

x>y, a<b, ax<by, all integers are not greater than 10000

analyze

 

the code

#include <iostream>
#include <cstdio>  
using namespace std;  
int main()  {  
	double x,a,y,b;  
	cin>>x>>a>>y>>b;  
	printf("%.2lf",(y*b-x*a)/(b-a));  
}

 

Guess you like

Origin blog.csdn.net/u013288190/article/details/132152432