codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

77.md (1077B)


      1 Source: https://codeforces.com/blog/entry/1769
      2 
      3 My solution for this task.
      4 
      5 We need discriminant to be above zero, so we have:
      6 
      7 p - 4q >= 0
      8 
      9 p >= 4q
     10 
     11 What is probability? It's relation of needed events to all. In this case needed events are all pairs (p,q) where p >= 4q
     12 
     13 All events are all possible pairs (p,q)
     14 
     15 How we can count them?
     16 
     17 All possible pairs is Cartasian product. We can draw it like rectangle.
     18 
     19 Its area - number of all possible pairs.
     20 
     21 Also we need to find area of polygon, where p >= 4q.
     22 
     23 For this let's draw line y=4x and needed set of points is above this line.
     24 
     25 Our answer is relation between this area and area of whole rectangle.
     26 
     27 I think finding areas isn't problem.
     28 
     29 There is one case that I draw on second image, when 4b < a
     30 
     31 There are 2 cases - when a=0 and b=0
     32 
     33 When a=0 we have only left part of image, so answer is 0.5
     34 
     35 When b=0 we have vertical line, so answer is 1.0
     36 
     37 Sorry for some mistakes in English.
     38 
     39 ![](/predownloaded/68/b4/68b4dc0894eaf043f47f55af361b054a23fa4417.png)![](/predownloaded/2b/b0/2bb01cca19ab594d6286fbf8a0ad464f9ed81684.png)