Hdoj 2552 (math]

Source: Internet
Author: User

Triplicate time limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others) Total submission (s): 2412 accepted submission (s): 1340

Problem descriptionmca talented people in the mountains, understanding the outside world war, the heroes of the mountains decided to save the people in the water fire, had to count the whole whisky, once hundreds of thousands of days of foreign customers, once a decade of yundun, and yundun are the allies of yundun, ranking in each of the national fortress (called the National Competition for short) and defeating the enemy, and finally fighting back the Liao army in case of Buddha and Buddha, the three-member position is also in the steady state.

Unfortunately, Liao vowed not to be reconciled. Liao guozheng South General <Yalu javac ++> wanted to find out where the three men were located one by one, and now he found the location of whisky S, the location of the tourists U, however, it is difficult to find out where yifenfei V is located. Only three people can satisfy the relationship:

Arctan (1/S) = arctan (1/u) + arctan (1/V)

Note: (0 <= x <= 1)
Define F (S, U, V) = V * u-s * V as <triplicate>

<Yalu javac ++> calculate the value of <triplicate>
 
Input input a T, indicating that there is a T group of data, followed by the T line:
Input S, U (S <= 12 ^ 3, u <= 2 ^ 20 and S, U, V> 0)
And S, U, and V are real numbers.
 
Output v * u-s * V value. For the sake of simplicity, if it is a decimal, It is rounded up directly.

For example, if the answer is 1.7, 1 is output.

 
Sample Input
11 2
 
Sample output
1
  Analysis: If you know that atan is an arctan, it is easy to do, but it will still be wa, because the double type is defined as a floating point type, so it is possible to get an error directly. For example, if the input is S = 2, the input may be S is actually 2.0000001, or 1.999999999. If this is the case, the result is an error, one is to add 0.1 after the result is calculated, and the other is to use. lf, rounding it down.


Code:

# Include <stdio. h> # include <string. h> # include <math. h> int main () {double S, U, V; int t; scanf ("% d", & T); While (t --) {scanf ("% lf", & S, & U); V = 1.0/(TAN (atan (1.0/S)-atan (1.0/U ))); printf ("%. LF \ n ", (u * V-S * (U + V); // you can change it to printf (" % d \ n ", (INT) (u * V-S * (U + V) + 0.1);} return 0 ;}



Hdoj 2552 (math]

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.