题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5761
题目:

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

首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法。

先分解v1v_1v​1​​,

设船到原点的距离是rrr,容易列出方程

drdt=v2cosθ−v1\frac{ dr}{ dt}=v_2\cos \theta-v_1​dt​​dr​​=v​2​​cosθ−v​1​​

dxdt=v2−v1cosθ\frac{ dx}{ dt}=v_2-v_1\cos \theta​dt​​dx​​=v​2​​−v​1​​cosθ

上下界都是清晰的,定积分一下:

0−a=v2∫0Tcosθdt−v1T0-a=v_2\int_0^T\cos\theta{ d}t-v_1T0−a=v​2​​∫​0​T​​cosθdt−v​1​​T

0−0=v2T−v1∫0Tcosθdt0-0=v_2T-v_1\int_0^T\cos\theta{ d}t0−0=v​2​​T−v​1​​∫​0​T​​cosθdt

直接把第一个式子代到第二个里面

v2T=v1v2(−a+v1T)v_2T=\frac{v_1}{v_2}(-a+v_1T)v​2​​T=​v​2​​​​v​1​​​​(−a+v​1​​T)

T=v1av12−v22T=\frac{v_1a}{{v_1}^2-{v_2}^2}T=​v​1​​​2​​−v​2​​​2​​​​v​1​​a​​

这样就很Simple地解完了,到达不了的情况就是v1<v2v_1< v_2v​1​​<v​2​​(或者a>0a>0a>0且v1=v2v_1=v_2v​1​​=v​2​​)。

#include <iostream>
#include<cstdio>
#include<cmath>using namespace std;int main()
{double a,v1,v2;while(~scanf("%lf%lf%lf",&a,&v1,&v2)){if(a==0)    printf("0\n");else if(v1>v2) printf("%.10f\n",(double)a*v1/(v1*v1-v2*v2));else    printf("Infinity\n");}
}

2016 Multi-University Training Contest 3 1010 Rower Bo相关推荐

  1. 2018 Multi-University Training Contest 8 1010 Taotao Picks Apples【二分】

    http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1010&cid=809 题意:求上升序列(能上升则上升无需最长),有修改 ...

  2. HDU 5761 Rower Bo(积分)

    题目链接:HDU 5761 题面: Rower Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K ( ...

  3. 2016 Multi-University Training Contest 10

    solved 7/11 2016 Multi-University Training Contest 10 题解链接 分类讨论 1001 Median(BH) 题意: 有长度为n排好序的序列,给两段子 ...

  4. 2016 Multi-University Training Contest 3

    A - Sqrt Bo 签到题啦,直接套一个大数模板搞定. 不过我现在使用的大数模板不支持直接定义并赋值,bignum a = 1 这样是不行的. //查看了下代码发现,模板中bignum的构造函数, ...

  5. 2017 Multi-University Training Contest - Team 7:1010. Just do it(组合数?)

    其他题目题解: 2017 Multi-University Training Contest - Team 7:1005. Euler theorem 2017 Multi-University Tr ...

  6. HUST-2015 Multi-University Training Contest 9

    2015 Multi-University Training Contest 9 solutions BY xudyh 1001.Expression 记dp_{l,r}dp​l,r​​表示l,rl, ...

  7. 2017 Multi-University Training Contest - Team 7:1003. Color the chessboard(...)

    其他题目题解: 2017 Multi-University Training Contest - Team 7:1005. Euler theorem 2017 Multi-University Tr ...

  8. 2017 Multi-University Training Contest - Team 7:1002. Build a tree(递归)

    其他题目题解: 2017 Multi-University Training Contest - Team 7:1005. Euler theorem 2017 Multi-University Tr ...

  9. 2017 Multi-University Training Contest - Team 7:1008. Hard challenge(模拟)

    其他题目题解: 2017 Multi-University Training Contest - Team 7:1005. Euler theorem 2017 Multi-University Tr ...

最新文章

  1. 基于GeoMipmap的地形系统。
  2. Mysql---之Mysqladmin修改账号密码方式
  3. php where or,php – laravel中whereOr和orWhere之间的区别
  4. C#中的Dictionary字典类介绍(转载)
  5. php 置信区间 计算,深度学习篇-如何理解置信区间
  6. 蓝牙鼠标windows linux,Ubuntu下使用蓝牙无线鼠标[图]
  7. python IDLE添加行号显示
  8. go -生成pb文件 - 上
  9. 我在GNU/Linux下使用的桌面环境工具组合
  10. CSS盒模型(Box Model)
  11. 2022年 hust OJ 最新搭建方式
  12. 基于stm32f401的双按键可视化多模式选择模块
  13. 新媒传信Java_新媒小课堂——多媒体、流媒体、富媒体
  14. 基于Qt开发的AES文件加解密工具
  15. (转)如何快速学习Tableau Desktop
  16. arduino控制超声波传感器
  17. ipv4ipv6导致微信H5支付问题
  18. FS4412开发板简介
  19. 北京社保定点医院查询
  20. 虚拟化服务器拓扑结构图,6-4简单虚拟化数据中心拓扑图介绍

热门文章

  1. [2021.10.30][uml]UML顺序图规范
  2. 研发团队中最合适的开发测试比是多少?
  3. mysql连接access失败_我用工具怎么连接不上mysql数据库的? MySql access denied for user错误...
  4. 斐讯路由器(K2P)解决DNS污染问题
  5. Cravatar头像
  6. 《天道》之丁元英的30句经典语录
  7. 苹果平板可以用html么,哪些苹果平板可以用苹果笔
  8. Vue+vant使用uploader上传图片
  9. mysql管理工具10.1,NavicatforMySQL10
  10. 基于Dragonboard 410c的PMIC简介