代码改变世界

UVa 10773 - Back to Intermediate Math

2017-06-06 21:43  tlnshuju  阅读(153)  评论(0编辑  收藏  举报

题目:渡河问题。给你河水宽度,水流速度,求垂直渡河与最快渡河的时间差。

分析:物理题,数学题。

               最快渡河情况,传垂直运动,垂直渡河,船的水平分速度和水流速度抵消。

说明:注意水流速度不能为0。

#include <cstdio>
#include <cmath>

int main()
{
	int T;
	scanf("%d",&T);
	for (int t = 1 ; t <= T ; ++ t) {
		double d,v,u;
		scanf("%lf%lf%lf",&d,&v,&u);

		printf("Case %d: ",t);
		if (u > v && v)
        	printf("%.3lf\n",d/sqrt(u*u-v*v)-d/u);
		else printf("can't determine\n");
	}
	return 0;
}