Rower Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1738 Accepted Submission(s): 678
Special Judge
Problem Description
There is a river on the Cartesian coordinate system,the river is flowing along the x-axis direction.
Rower Bo is placed at (0,a) at first.He wants to get to origin (0,0) by boat.Boat speed relative to water is v1 ,and the speed of the water flow is v2 .He will adjust the direction of v1 to origin all the time.
Your task is to calculate how much time he will use to get to origin.Your answer should be rounded to four decimal places.
If he can't arrive origin anyway,print"Infinity"(without quotation marks).
Rower Bo is placed at (0,a) at first.He wants to get to origin (0,0) by boat.Boat speed relative to water is v1 ,and the speed of the water flow is v2 .He will adjust the direction of v1 to origin all the time.
Your task is to calculate how much time he will use to get to origin.Your answer should be rounded to four decimal places.
If he can't arrive origin anyway,print"Infinity"(without quotation marks).
Input
There are several test cases. (no more than 1000)
For each test case,there is only one line containing three integers a,v1,v2 .
0≤a≤100 , 0≤v1,v2,≤100 , a,v1,v2 are integers
For each test case,there is only one line containing three integers a,v1,v2 .
0≤a≤100 , 0≤v1,v2,≤100 , a,v1,v2 are integers
Output
For each test case,print a string or a real number.
If the absolute error between your answer and the standard answer is no more than 10−4 , your solution will be accepted.
If the absolute error between your answer and the standard answer is no more than 10−4 , your solution will be accepted.
Sample Input
2 3 3 2 4 3
Sample Output
Infinity 1.1428571429
这是一个物理题.....一开始以为是很简单的小船过河问题,后来发现不是,因为题目说船的速度方向是时刻指向原点的,也就是说他是一个变化的过程。
然后对其进行分析,我们先对船的速度v1进行分解且对船的水平位移进行分析,在水平方向上,船的位移是0,然后我们可以得出船的水平瞬时速度公式。
这就是水平方向上的公式了,为什么右边是v2-v1cos..因为当v2大于v1时,v2肯定是大于v1的水平分速度的,所以等号右边是小船的水平分速度,又因为水平位移为0,所以等号左边是0,我们就可以得出v2和v1的关系v2=v1cosθ
然后我们看船头方向,
我们设船到原点的距离是y(直线距离),看图中的角度关系,根据平行四边形法则,我们可以得出
等号右边是船头方向的总速度,等号左边是什么呢?我们加上积分的那个符号(就是f少了一行那个),这样,左边就变成了0到t时间上y轴的位移也就是a,然后再结合上一步得出来的关系式,就写出来啦~
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int a,v1,v2;
while(cin>>a>>v1>>v2){
if(!a){
cout<<0<<endl;
continue;
}
if(v1<=v2) cout<<"Infinity"<<endl;
else{
cout<<a*v1*1.0/(v1*v1-v2*v2)<<endl;
}
}
}