地球人口承载力估计 解析和C++代码

Description

假设地球上的新生资源按恒定速度增长。照此测算,地球上现有资源加上新生资源可供x亿人生活a年,或供y亿人生活b年。 为了能够实现可持续发展,避免资源枯竭,地球最多能够养活多少亿人?

Input

一行,包括四个正整数x,a,y,b,两个整数之间用单个空格隔开

Output

一个实数,表示地球最多养活几亿人,保留两位小数。

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,各整数均不大于10000

解析

代码

#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));  
}

猜你喜欢

转载自blog.csdn.net/u013288190/article/details/132152432
今日推荐