hdu-5761 Rower Bo(数学) Rower Bo

题目链接:

Time Limit: 2000/1000 MS (Java/Others)   

 Memory Limit: 131072/131072 K (Java/Others)

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 
 
Input
There are several test cases. (no more than 1000)

For each test case,there is only one line containing three integers 2 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 4, your solution will be accepted.
 
Sample Input
 
2 3 3
2 4 3
 
Sample Output
 
Infinity
1.1428571429
 
题意:
 
给小船的初始位置,水的流速,小船相对于水的速度;现在小船每刻的方向都朝向原点,问小船到达原点的用时是多少;
 
思路:
 
我太笨了,当时比赛的时候就不会做;后来看的题解;
 
http://bestcoder.hdu.edu.cn/blog/2016-multi-university-training-contest-3-solutions-by-%E7%BB%8D%E5%85%B4%E4%B8%80%E4%B8%AD/
 
AC代码:
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
//#include <bits/stdc++.h>
#include <stack>

using namespace std;

#define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss));

typedef  long long LL;

template<class T> void read(T&num) {
    char CH; bool F=false;
    for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
    for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
    F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
    if(!p) { puts("0"); return; }
    while(p) stk[++ tp] = p%10, p/=10;
    while(tp) putchar(stk[tp--] + '0');
    putchar('
');
}

const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=2e6+10;
const int maxn=500+10;
const double eps=1e-8;


int main()
{       
        double a,v1,v2;
        while(scanf("%lf%lf%lf",&a,&v1,&v2)!=EOF)
        {

            if(v1<=v2)
            {
                if(v1<=v2&&a>0)printf("Infinity
");
                else printf("0
");
            }
            else 
            {
                printf("%.6lf
",1.0*v1*a/(v1*v1-v2*v2));
            }
        }
        
        return 0;
}