hdu 5761 Rowe Bo 微分方程

1010 Rower Bo

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

先分解v_1v?1??,

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

\frac{ dr}{ dt}=v_2\cos \theta-v_1?dt??dr??=v?2??cosθ−v?1??

\frac{ dx}{ dt}=v_2-v_1\cos \theta?dt??dx??=v?2??−v?1??cosθ

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

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

0-0=v_2T-v_1\int_0^T\cos\theta{ d}t0−0=v?2??T−v?1??∫?0?T??cosθdt

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

v_2T=\frac{v_1}{v_2}(-a+v_1T)v?2??T=?v?2????v?1????(−a+v?1??T)

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

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

1011 Teacher Bo

考虑一种暴力,每次枚举两两点对之间的曼哈顿距离,并开一个桶记录每种距离是否出现过,如果某次枚举出现了以前出现的距离就输 YESYES ,否则就输 NONO .

注意到曼哈顿距离只有 O(M)O(M) 种,根据鸽笼原理,上面的算法在 O(M)O(M) 步之内一定会停止.所以是可以过得.

一组数据的时间复杂度 O(\min{N^2,M})O(min{N?2??,M}) .

Rower Bo

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1248    Accepted Submission(s): 474
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).

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

Author

绍兴一中

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
    int a,v1,v2;
    while(~scanf("%d%d%d",&a,&v1,&v2))
    {
        if(a==0) {printf("0.000\n");continue;}
        if(v1<=v2)
        {
            printf("Infinity\n");
        }
        else
        {
            double v=(v1*v1-v2*v2)+0.0;

            double ans=(a*v1*1.0)/v;
            printf("%.12lf\n",ans);
        }
    }
    return 0;
}

时间: 2024-08-05 06:41:50

hdu 5761 Rowe Bo 微分方程的相关文章

【数学】HDU 5761 Rower Bo

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 题目大意: 船在(0,a),船速v1,水速v2沿x轴正向,船头始终指向(0,0),问到达(0,0)用时,无解输出Infinity. 题目思路: [数学] 说是数学其实更像物理. 很明显v1<=v2时无解. 这道题列积分方程然后解出来式子是t=a*v1/(v12-v22). 我列积分方程的时候少了一个式子没解出来. 可以看看半根毛线的.http://images2015.cnblogs.com

hdu 5758 Explorer Bo(树形dp)

题目链接:hdu 5758 Explorer Bo 题意: 给一棵n个点的树,每次任选两个点,然后覆盖两点间的所有边,要求以最少的次数覆盖所有的边,在保证次数最少的情况下要求覆盖边的总次数最小 题解: 详细题解传送门 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=(a);i<=(b);++i) 3 using namespace std; 4 5 const int N=1e5+7; 6 int t,n,x,y,sz[N],

HDU 5752 Sqrt Bo【枚举,大水题】

Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2221    Accepted Submission(s): 882 Problem Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y wh

【数学】HDU 5753 Permutation Bo

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为1,假为0. 函数f(h)=(i=1~n)∑ci[hi>hi−1 && hi>hi+1] 现在给定c的值,求f(h)的期望. 题目思路: [数学] 头尾的概率为1/2,中间的概率为1/3,直接求和. 1 // 2 //by coolxxx 3 // 4 #include<io

【模拟】HDU 5752 Sqrt Bo

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 题目大意: 定义f(n)=⌊√n⌋,fy(n)=f(fy-1(n)),求y使得fy(n)=1.如果y>5输出TAT.(n<10100) 题目思路: [模拟] 5层迭代是232,所以特判一下层数是5的,其余开根号做.注意数据有0. 队友写的. 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h&g

【模拟】HDU 5762 Teacher Bo

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 题目大意: 给n个点,坐标范围0~m(n,m<=105),求是否存在2个点对满足哈夫曼距离相等. 题目思路: [模拟] 乍一看n2绝对T了,但是细想之下发现,坐标范围只有105,那么哈夫曼距离最多就2x105种,所以当循环超出这个范围时肯定能找到解(抽屉原理). 1 // 2 //by coolxxx 3 // 4 #include<iostream> 5 #include<a

HDU 5758 Explorer Bo(树形DP)

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5758 [题目大意] 给出一棵树,每条路长度为1,允许从一个节点传送到任意一个节点,现在要求在传送次数尽量少的情况下至少经过每条路一遍啊,同时最小化走过的路程总长度.输出路程总长度. [题解] 首先,对于传送次数尽量少这个条件,我们很容易发现,当且仅当每次出发点和终止点都是叶节点的时候,是最少的,当然在叶节点无法两两匹配的时候,再多走一条链. 然后就是叶节点的匹配问题,使得匹配后的叶节点连线覆盖全

hdu 5752 Sqrt Bo

Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 980    Accepted Submission(s): 452 Problem Description Let's define the function f(n)=⌊n√⌋. Bo wanted to know the minimum number y which

hdu 5762 Teacher Bo 曼哈顿路径

Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1014    Accepted Submission(s): 561 Problem Description Teacher BoBo is a geography teacher in the school.One day in his class,he mar