UVa 10693 Traffic Volume (数学&物理模型)

本文探讨了在无限长街道上,如何通过调整车辆速度来最大化单位时间内通过某点的车辆数量。文中给出了一种数学模型,通过设定车辆速度、长度及减速率,计算出最优速度,使得交通流量达到最大值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

10693 - Traffic Volume

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=467&page=show_problem&problem=1634

In the picture below (or above depending on HTML response :)) you can see a street. It has infinite number of cars on it. The distance between any two consecutive cars is d, length of each car is L and the velocity of each car is v. The volume of cars through a road means the number of cars passing through a road in a specific amount of time. When the velocity is constant, d must be minimum for the volume of cars passing through the road to be maximal. In our model when the velocity of all the cars is v then the minimum possible value of d is v²/(2f) (The more the car velocity the more distance you need to bring down your velocity to zero). Here f is the deceleration due to break.

Keeping this model in mind and given the value of L and f your job is to find the value of v for which the volume of traffic through the road is maximal.

 

Input

The input file contains several lines of input. Each line of input contains two integers L (0<L<=100) and f(0<f<=10000). The unit of L is meter and the unit of f is meter/second². The input is terminated by a single line whose value of L and is zero.

 

Output

For each line of input except the last one produce one line of output. Each line contains two floating-point number v and volume separated by a single space. Here v is the velocity for which traffic flow is maximal and volume is the maximum number of vehicles (of course it is a fraction) passing through the road in an hour. These two floating points should have eight digits after the decimal. Errors less than 1e-5 will be ignored.

 

Sample Input    Output for Sample Input

5 30 
0             

5.47722558 1971.80120702


首先要使每辆车通过某个点的所用时间最少,即(l+v*v/2f)/v=l/v+v/2f最少,所以当v=sqrt(2fl)时满足题意。


完整代码:

/*0.009s*/

#include<cstdio>
#include<cmath>

int main(void)
{
	int l, f;
	while (scanf("%d%d", &l, &f), l)
	{
		f <<= 1;
		printf("%f %f\n", sqrt(l * f), 1800 * sqrt((double)f / l));
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值