codeforces-scrape

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

911B.md (2003B)


      1 Source: https://codeforces.com/problemset/problem/911/B
      2 
      3 B. Two Cakes
      4 
      5 time limit per test
      6 
      7 1 second
      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 It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bought two cakes and cut them into pieces: the first cake has been cut into *a* pieces, and the second one — into *b* pieces.
     22 
     23 Ivan knows that there will be *n* people at the celebration (including himself), so Ivan has set *n* plates for the cakes. Now he is thinking about how to distribute the cakes between the plates. Ivan wants to do it in such a way that all following conditions are met:
     24 
     25 1. Each piece of each cake is put on some plate;
     26 2. Each plate contains at least one piece of cake;
     27 3. No plate contains pieces of both cakes.
     28 
     29 To make his guests happy, Ivan wants to distribute the cakes in such a way that the minimum number of pieces on the plate is maximized. Formally, Ivan wants to know the maximum possible number *x* such that he can distribute the cakes according to the aforementioned conditions, and each plate will contain at least *x* pieces of cake.
     30 
     31 Help Ivan to calculate this number *x*!
     32 
     33 Input
     34 
     35 The first line contains three integers *n*, *a* and *b* (1 ≤ *a*, *b* ≤ 100, 2 ≤ *n* ≤ *a* + *b*) — the number of plates, the number of pieces of the first cake, and the number of pieces of the second cake, respectively.
     36 
     37 Output
     38 
     39 Print the maximum possible number *x* such that Ivan can distribute the cake in such a way that each plate will contain at least *x* pieces of cake.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 5 2 3
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 1
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 4 7 10
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 3
     65 ```
     66 
     67 Note
     68 
     69 In the first example there is only one way to distribute cakes to plates, all of them will have 1 cake on it.
     70 
     71 In the second example you can have two plates with 3 and 4 pieces of the first cake and two plates both with 5 pieces of the second cake. Minimal number of pieces is 3.