codeforces-scrape

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

794B.md (1917B)


      1 Source: https://codeforces.com/problemset/problem/794/B
      2 
      3 B. Cutting Carrot
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into *n* pieces of equal area.
     22 
     23 Formally, the carrot can be viewed as an isosceles triangle with base length equal to 1 and height equal to *h*. Igor wants to make *n* - 1 cuts parallel to the base to cut the carrot into *n* pieces. He wants to make sure that all *n* pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?
     24 
     25  ![](https://espresso.codeforces.com/4b5882003a2fb68baaa7cb8a61c7677a76f0bbcd.png) Illustration to the first example.
     26 
     27 Input
     28 
     29 The first and only line of input contains two space-separated integers, *n* and *h* (2 ≤ *n* ≤ 1000, 1 ≤ *h* ≤ 105).
     30 
     31 Output
     32 
     33 The output should contain *n* - 1 real numbers *x*1, *x*2, ..., *x**n* - 1. The number *x**i* denotes that the *i*-th cut must be made *x**i* units away from the apex of the carrot. In addition, 0 < *x*1 < *x*2 < ... < *x**n* - 1 < *h* must hold.
     34 
     35 Your output will be considered correct if absolute or relative error of every number in your output doesn't exceed 10- 6.
     36 
     37 Formally, let your answer be *a*, and the jury's answer be *b*. Your answer is considered correct if ![](https://espresso.codeforces.com/1c85fc8f47323706e20bcb6c9d491c7d1192fadf.png).
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3 2
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 1.154700538379 1.632993161855
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 2 100000
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 70710.678118654752
     63 ```
     64 
     65 Note
     66 
     67 Definition of isosceles triangle: <https://en.wikipedia.org/wiki/Isosceles_triangle>.