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

2024-03-05 20:38

本文主要是介绍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));elseputs("can't determine");}return 0;
}

这篇关于UVa 10773 Back to Intermediate Math (数学速度的分解陷阱)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/777744

相关文章

【Linux进阶】UNIX体系结构分解——操作系统,内核,shell

1.什么是操作系统? 从严格意义上说,可将操作系统定义为一种软件,它控制计算机硬件资源,提供程序运行环境。我们通常将这种软件称为内核(kerel),因为它相对较小,而且位于环境的核心。  从广义上说,操作系统包括了内核和一些其他软件,这些软件使得计算机能够发挥作用,并使计算机具有自己的特生。这里所说的其他软件包括系统实用程序(system utility)、应用程序、shell以及公用函数库等

Python分解多重列表对象,isinstance实现

“”“待打印的字符串列表:['ft','bt',['ad',['bm','dz','rc'],'mzd']]分析可知,该列表内既有字符对象,又有列表对象(Python允许列表对象不一致)现将所有字符依次打印并组成新的列表”“”a=['ft','bt',['ad',['bm','dz','rc'],'mzd']]x=[]def func(y):for i in y:if isinst

OSG数学基础:坐标系变换

三维实体对象需要经过一系列的坐标变换才能正确、真实地显示在屏幕上。在一个场景中,当读者对场景中的物体进行各种变换及相关操作时,坐标系变换是非常频繁的。坐标系变换通常包括:世界坐标系-物体坐标系变换、物体坐标系-世界坐标系变换和世界坐标系-屏幕坐标系变换(一个二维平面坐标系,即显示器平面,是非常标准的笛卡尔坐标系的第一象限区域)。 世界坐标系-物体坐标系变换 它描述的问题主要是关于物体本身的

OSG数学基础:坐标系统

坐标系是一个精确定位对象位置的框架,所有的图形变换都是基于一定的坐标系进行的。三维坐标系总体上可以分为两大类:左手坐标系和右手坐标系。常用的坐标系:世界坐标系、物体坐标系和摄像机坐标系。 世界坐标系 世界坐标系是一个特殊的坐标系,它建立了描述其他坐标系所需要的参考框架。从另一方面说,能够用世界坐标系来描述其他坐标系的位置,而不能用更大的、外部的坐标系来描述世界坐标系。世界坐标系也被广泛地

高性能MYsql读书笔记-加快alter table操作的速度

alte tabe 会导致事务中断。 方法1  使用 alter column 代替 modify column  方法2  不推荐。。 ALTER TABLE      [  ALTER COLUMN    / MODIFY COLUMN  /  CHANGE COLUMN  ] ALTER TABLE sakila.film MODIFY COLUMN rental

redis增大查询速度(项目中实际应用举例)

1、关于保存User表的方案       1.1  使用Redis的Hash类型去保存关系型数据库的User表        1.2 redis的Hash的key为"SYS_USER_TABLE_SEX_MAN",field:userid   value:json 数据 2、利用Redis的Set来保存满足一类条件的User用户的id信息。例如,性别为女,年龄大于25岁等条件。 3

为何HBase速度很快?

为何HBase速度很快? HBase能提供实时计算服务主要原因是由其架构和底层的数据结构决定的, 即由LSM-Tree(Log-Structured Merge-Tree) + HTable(region分区) + Cache决定——客户端可以直接定位到要查数据所在的HRegion server服务器,然后直接在服务器的一个region上查找要匹配的数据,并且这些数据部分是经过cache缓存的。

UVA - 12206 Stammering Aliens (hash)

这题其实很容易想到2分长度,关键是2分后,怎么判断出现最多次的串是否》=m次了。这里需要用到hash来处理。 对于一个字符串   H[i] =H[i+1]*131+s[i]  ;其中 H[n]=0;那么对于一个长度为L的串 ,hanh[i,l]=H[i]-H[i+L]*x^L ; 这样记录每个字符串的hash值,然后再处理起来就比较简单了。 VIEW CODE #include<

【进阶篇-Day5:JAVA常用API的使用(Math、BigDecimal、Object、包装类等)】

目录 1、API的概念2、Object类2.1 Object类的介绍2.2 Object的toString()方法2.3 Object的equals()方法2.4 Objects概述 3、Math类4、System类5、BigDecimal类6、包装类6.1 包装类的概念6.2 几种包装类(1)手动转换包装类:(2)自动转换包装类:(3)Integet常用方法:(4)练习: 1

2023-2024 学年第二学期小学数学六年级期末质量检测模拟(制作:王胤皓)(90分钟)

word效果预览: 一、我会填 1. 1.\hspace{0.5em} 1. 一个多位数,亿位上是次小的素数,千位上是最小的质数的立方,十万位是 10 10 10 和 15 15 15 的最大公约数,万位是最小的合数,十位上的数既不是质数也不是合数,这个数是 ( \hspace{4em} ),约等于 ( \hspace{1em} ) 万 2. 2.\hspace{0.5em} 2.