UVa 10773 Back to Intermediate Math (数学&速度的分解&陷阱)

10773 - Back to Intermediate Math

Time limit: 3.000 seconds

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

Umm! So, you claim yourself as an intelligent one? Let me check. As, computer science students always insist on optimization whenever possible, I give you an elementary problem of math to optimize.

 

You are trying to cross a river of width d meters. You are given that, the river flows at v ms-1 and you know that you can speed up the boat inu ms-1. There may be two goals how to cross the river: One goal (called fastest path) is to cross it in fastest time, and it does not matter how far the flow of the river takes the boat. The other goal (called shortest path) is to steer the boat in a direction so that the flow of the river doesn't take the boat away, and the boat passes the river in a line perpendicular to the boarder of the river. Is it always possible to have two different paths, one to pass at shortest time and the other at shortest path? If possible then, what is the difference (Let  P s) between the times needed to cross the river in the different ways?

 

Input

 

The first line in the input file is an integer representing the number of test cases. Each of the test cases follows below. Each case consists three real numbers (all are nonnegative, d is positive) denoting the value of dv and u respectively.


Output

 

For each test case, first print the serial number of the case, a colon, an space and then print "can't determine" (without the quotes) if it is not possible to find different paths as stated above, else print the value of corrected to three digits after decimal point. Check the sample input & output.

 

Sample Input

3

8 5 6

1 2 3

1 5 6

Sample Output

Case 1: 1.079
Case 2: 0.114
Case 3: 0.135


请回忆物理必修2。


完整代码:

/*0.015s*/

#include<cstdio>
#include<cmath>

int main(void)
{
	int test, i;
	int d, u, v;
	scanf("%d", &test);
	for (i = 1; i <= test; i++)
	{
		scanf("%d%d%d", &d, &v, &u);
		printf("Case %d: ", i);
		if (u > v && v)///陷阱:v不能为0,因为题目要求是"two different paths"
			printf("%.3f\n", d * (1.0 / sqrt(u * u - v * v) - 1.0 / u));
		else
			puts("can't determine");
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值