UVA-11346 probability (probability)

Source: Internet
Author: User

Description

Probability

Time limit:1 sec Memory limit:16mb

Consider rectangular coordinate system and point L (x, y) which is randomly chosen among all points in the area A which is D Efined in the following manner:a = {(x, y) | x is from interval [-a;a]; y was from interval [-b;b]}. What's the probability P that's the area of a rectangle that's defined by points (0,0) and (x, y) would be greater than S?

INPUT:

The number of tests N <= are given on the first line of input. Then N lines with the 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 should output one number P and percentage " % " symbol following Line. P must is rounded to 6 digits after decimal point.

SAMPLE INPUT:
310 5 201 1 12 2 0
SAMPLE OUTPUT:
 23.348371%0.000000%100.000000%题意:给定a,b,s要求在[-a,a]选定x,在[-b,b]选定y,使得(0, 0)和(a,b)组成的矩形面积大于s的概率思路:只需要求第一象限的即可,转换成a*b>s的图形面积,利用求导函数求面积的方式计算,总面积为m=a*b,求所以概率为(m-s-s*log(m/s))/m.
#include <iostream>#include<cstdio>#include<cmath>using namespacestd;intMain () {intnum; scanf ("%d",&num);  while(num--){        Doublea,b,s; scanf ("%LF%LF%LF",&a,&b,&s); if(S > A *b) printf ("0.000000%%\n"); Else if(s = =0) printf ("100.000000%%\n"); Else{            Doublem = A *b; DoubleAns = (m-s-S * log (M/s))/m; printf ("%.6lf%%\n", ans* -); }    }    return 0;}

UVA-11346 probability (probability)

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.