UVa 10773 back to Intermediate math (Math & Speed Decomposition & traps)

Source: Internet
Author: User
Tags printf time limit

10773-back to Intermediate Math

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php? Option=com_onlinejudge&itemid=8&category=467&page=show_problem&problem=17 14

umm! So, claim yourself as a intelligent one? Let me check. As, computer students always insist on optimization whenever-possible, I give you a elementary problem of math to Optimize.

You are are trying to cross a river of width d meters. You are are given that, the river flows in v ms-1 and you know this can speed up the boat in u Ms-1. There may being two goals to cross the River:one goal (called fastest path) are to cross it in fastest time, and it does Not matter how far the river takes the boat. The other goal (called Shortest path) are to steer the boat in a direction so this flow of the river doesn ' t take the B Oat away, and the boat passes the river in a line perpendicular to the boarder of the river. Are it always possible to have two different paths, one to pass at shortest time and the other at shortest path? If possible then, what is the difference (let P s) between the Times needed to cross the river in T He different ways?

Input

The the ' the ' ' input ' is ' an integer representing the number of test cases. Each of the test cases follows below. Each case consists three real numbers (all are nonnegative, D is positive) denoting the value of D, V and u respectively.


Output

For the all test case, the serial number of the, a colon, and then print "can ' t determine" (without the quotes) if it isn't possible to find different paths as stated above, else print the value of P Corrected to three digits on decimal point. Check the sample input & output.

Sample Input

3

8 5 6

1 2 3

1 5 6

Sample Output

Case 1:1.079
Case 2:0.114
Case 3:0.135

Please recall the physical compulsory 2.

Complete code:

/*0.015s*/
  
#include <cstdio>
#include <cmath>
  
int main (void)
{
    int test, I;
    int d, u, v;
    scanf ("%d", &test);
    for (i = 1; I <= test; i++)
    {
        scanf ("%d%d%d", &d, &v, &u);
        printf ("Case%d:", i);
        if (U > v && v)///Trap: v cannot be 0 because the title requires "two different 

paths"
            printf ("%.3f\n", D * (1.0/sqrt (U * u-v * V)-1.0/u);
        Else
            puts ("can ' t determine");
    }
    return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.