UV-11346 Probability (Probability)

Source: Internet
Author: User

UV-11346 Probability (Probability)

Description

G-Probability

Time Limit: 1 sec
Memory Limit: 16 MB

Consider rectangular coordinate system and point L (X, Y) which is randomly chosen among all points in the area A which is defined in the following manner: A = {(x, y) | x is from interval [-a; a]; y is from interval [-B; B]}. what is the probability P that the area of a rectangle that is defined by points (0, 0) and (X, Y) will be greater than S?

INPUT: The number of tests N <= 200 is given on the first line of input. then N lines with one test case on each line follow. the test consists of 3 real numbers a> 0, B> 0 ir S => 0. OUTPUT: For each test case you shoshould output one number P and percentage" %"Symbol following that number on a single line. P must be rounded to 6 digits after decimal point. sample input:
310 5 201 1 12 2 0
Sample output:
23.348371% 0.000000% 100.000000% question: Given a, B, and s, you must select x in [-a, a] AND y in [-B, B] to make (0, 0) the probability that the area of a rectangle composed of (x, y) is greater than the area of s. The thought is to convert it to the area of x * y> s, and calculate the area by using the guide function, y = s/x. The guiding function is y = s * lnx.
#include 
  
   #include 
   
    #include 
    
     #include #include 
     
      using namespace std;int main() {int t;double a, b, s;scanf("%d", &t);while (t--) {scanf("%lf%lf%lf", &a, &b, &s);if (a * b <= s) {puts("0.000000%");continue;}if (s == 0) {puts("100.000000%");continue;}printf("%lf%%\n", 100 - (s + s * (log(a) - log(s / b))) / a / b * 100);}return 0;}
     
    
   
  


Related Article

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.