hdu 5761 Rower Bo 微分方程
Rower Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 641 Accepted Submission(s): 199
Special Judge
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).
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
If the absolute error between your answer and the standard answer is no more than 10−4, your solution will be accepted.
2 4 3
1.1428571429
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int inf =0x7f7f7f7f;
const double pi=acos(-1);
const int mod=1e9+7;
const int maxn=100000+10;
ll f_2[1000+10]; #define FOR(i,n) for(int i=1;i<=n;i++)
#define SC scanf
#define PF printf int main()
{
int a,v1,v2;
while(~SC("%d%d%d",&a,&v1,&v2)){
if(a!=0&&v1<=v2) PF("Infinity\n");
else if(!a) PF("0\n");
else PF("%.9f\n",v1*a/((double)(v1*v1-v2*v2)));
}
return 0;
}
1010 Rower Bo
首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法。
先分解v_1v1,
设船到原点的距离是rr,容易列出方程
\frac{ dr}{ dt}=v_2\cos \theta-v_1dtdr=v2cosθ−v1
\frac{ dx}{ dt}=v_2-v_1\cos \thetadtdx=v2−v1cosθ
上下界都是清晰的,定积分一下:
0-a=v_2\int_0^T\cos\theta{ d}t-v_1T0−a=v2∫0Tcosθdt−v1T
0-0=v_2T-v_1\int_0^T\cos\theta{ d}t0−0=v2T−v1∫0Tcosθdt
直接把第一个式子代到第二个里面
v_2T=\frac{v_1}{v_2}(-a+v_1T)v2T=v2v1(−a+v1T)
T=\frac{v_1a}{{v_1}^2-{v_2}^2}T=v12−v22v1a
这样就很Simple地解完了,到达不了的情况就是v_1< v_2v1<v2(或者a>0a>0且v_1=v_2v1=v2)。
hdu 5761 Rower Bo 微分方程的更多相关文章
- hdu 5761 Rower Bo 物理题
Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...
- HDU 5761 Rower Bo
传送门 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Special Jud ...
- hdu 5761 Rowe Bo 微分方程
1010 Rower Bo 首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法. 先分解v_1v1, 设船到原点的距离是rr,容易列出方程 \frac{ dr} ...
- 【数学】HDU 5761 Rower Bo
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 题目大意: 船在(0,a),船速v1,水速v2沿x轴正向,船头始终指向(0,0),问到达(0, ...
- hdu-5761 Rower Bo(数学)
题目链接: Rower Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- HDU 5761 物理题
Rower Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- HDU 5752 Sqrt Bo (数论)
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...
- HDU 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
随机推荐
- 如何使用加多宝(jdb)在linux下调试Java程序
毕业时写了一段时间的C,那时候调试使用gdb,后来转了java,当时就想java程序怎么调试,找了一下,果然,那就是jdk自带的jdb windows里是这样的 Linux下是这样的 一般我在linu ...
- py2和py3之间的不同
1.print函数 很琐碎,而 print 语法的变化可能是最广为人知的了,但是仍值得一提的是: Python 2 的 print 声明已经被 print() 函数取代了,这意味着我们必须包装我们想打 ...
- 使用python的ctypes库实现内存的动态申请和释放
1.申请前内存占用情况 2.申请内存 from ctypes import * import time #在这里申请1G的内存,单位k mem = create_string_buffer(1024* ...
- linux常用的bash指令
文本处理 awk sed grep sort uniq cat cut echo fmt tr nl egrep fgrep wc 进程监视 ps top htop atop lsof 网络 nmap ...
- vue入门:(条件渲染)
v-if v-show v-else 一.v-if:生成或者移出一个元素 <div id="example"> <button v-on:click=" ...
- Java web 项目 web.xml 配置文件加载过程
转载自:http://blog.csdn.net/luoliehe/article/details/46884757#comments WEB加载web.xml初始化过程: 在启动Web项目时,容器( ...
- eval的使用
当逻辑字符串是拼接而成的时候可以用eval来判断真假 eg:let a= "22" let b = ">" let c = "1" 用 ...
- 使用hbuilder打包时,调用地图和相机
<template> <div class="comCon"> <!-- 你是头部区域的内容 --> <headback class=&q ...
- JavaWeb【JSTL】
根据JSTL标签所提供的功能,可以将其分为5个类别. 核心标签 格式化标签 SQL 标签 XML 标签 JSTL 函数 使用方式 1.下载包 地址:http://archive.apache.org/ ...
- UNetbootin安装linux
用u盘安装linux系统,最好的方法莫过于用UNetbootin,网址:http://unetbootin.github.io/ UNetbootin allows you to create boo ...