微分方程_______Rower Bo( HDU 5761 2016多校第三场)
2016-08-24 21:39
295 查看
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).
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
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.
Sample Input
2 3 3
2 4 3
Sample Output
Infinity
1.1428571429
题意:
最开始在(0,a)点有一艘船,水流方向朝向X轴正方向,速度为V1,船的速度为V2,船在行驶过程中速度方向一直朝向原点。问多久才能到达原点?
分析:
因为速度是变方向,所以要用积分来做,最开始我对距离积分没算出来,后来看了题解才知道要分别对X轴方向和斜轴方向积分。
,我们换一个思路,不分解v1分解v2,在斜方向上对速度积分,得到这样一个式子:
∫T0(v1−cosθ⋅v2) dt=a
可以看到在这样一个式子里,我们只有cosθ,于是我们把这个式子和前面在x轴方向上积分的式子
∫T0(v2−cosθ⋅v1) dt=0
联立,消去cosθ就行了。
最终得到
T=v1av21−v22
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a,v1,v2;
int main()
{
while(scanf("%d%d%d",&a,&v1,&v2)!=EOF)
{
if (a==0) { printf("0\n"); continue ; }
if (v1<=v2)
{
printf("Infinity\n");
continue ;
}
double t= 1.0*a*v1/(v1*v1-v2*v2);
printf("%lf\n",t);
}
return 0;
}
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).
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
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.
Sample Input
2 3 3
2 4 3
Sample Output
Infinity
1.1428571429
题意:
最开始在(0,a)点有一艘船,水流方向朝向X轴正方向,速度为V1,船的速度为V2,船在行驶过程中速度方向一直朝向原点。问多久才能到达原点?
分析:
因为速度是变方向,所以要用积分来做,最开始我对距离积分没算出来,后来看了题解才知道要分别对X轴方向和斜轴方向积分。
,我们换一个思路,不分解v1分解v2,在斜方向上对速度积分,得到这样一个式子:
∫T0(v1−cosθ⋅v2) dt=a
可以看到在这样一个式子里,我们只有cosθ,于是我们把这个式子和前面在x轴方向上积分的式子
∫T0(v2−cosθ⋅v1) dt=0
联立,消去cosθ就行了。
最终得到
T=v1av21−v22
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a,v1,v2;
int main()
{
while(scanf("%d%d%d",&a,&v1,&v2)!=EOF)
{
if (a==0) { printf("0\n"); continue ; }
if (v1<=v2)
{
printf("Infinity\n");
continue ;
}
double t= 1.0*a*v1/(v1*v1-v2*v2);
printf("%lf\n",t);
}
return 0;
}
相关文章推荐
- HDU-5761-Rower Bo(微分方程)
- UESTC第二届ACM趣味程序设计竞赛第三场
- 数值偏微分方程解法分类
- HDU 4512 HDOJ 吉哥系列故事——完美队形I --- 腾讯2013初赛第三场
- 金山西山居初赛第三场
- 2013 - ECJTU 暑期训练赛第三场-problem-E
- 杭电第三场水题1007
- 多校第三场——hdu4631——离线
- 大一暑假集训单切赛第三场
- 微分方程、动力系统与混沌导论 第6章 高维线性系统[书摘]
- [家里蹲大学数学杂志]第294期微分方程与数学物理问题习题集
- 2014多校联合-第三场
- [偏微分方程教程习题参考解答]2.3拟线性偏微分方程
- 国防科学技术大学第十八届银河之光文化节ACM程序设计竞赛初赛第三场 赛后小结
- 多校第三场 1002 hdu 5317 RGCDQ (筛素数+前缀和)
- hdu 5316 Magician(2015多校第三场第1题)线段树单点更新+区间合并
- hdu 5317 RGCDQ (2015多校第三场第2题)素数打表+前缀和相减求后缀(DP)
- ACM大一练习赛-第三场------H - 玻色-爱因斯坦凝聚态【二分查找】
- 2015年第五届ACM趣味编程循环赛(第三场) 题解
- 2016 计蒜之道 初赛 第三场 百度帐号的选取方案(中等) KMP