codeforces-scrape

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

628A.md (2014B)


      1 Source: https://codeforces.com/problemset/problem/628/A
      2 
      3 A. Tennis Tournament
      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 A tennis tournament with *n* participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.
     22 
     23 The tournament takes place in the following way (below, *m* is the number of the participants of the current round):
     24 
     25 * let *k* be the maximal power of the number 2 such that *k* ≤ *m*,
     26 * *k* participants compete in the current round and a half of them passes to the next round, the other *m* - *k* participants pass to the next round directly,
     27 * when only one participant remains, the tournament finishes.
     28 
     29 Each match requires *b* bottles of water for each participant and one bottle for the judge. Besides *p* towels are given to each participant for the whole tournament.
     30 
     31 Find the number of bottles and towels needed for the tournament.
     32 
     33 Note that it's a tennis tournament so in each match two participants compete (one of them will win and the other will lose).
     34 
     35 Input
     36 
     37 The only line contains three integers *n*, *b*, *p* (1 ≤ *n*, *b*, *p* ≤ 500) — the number of participants and the parameters described in the problem statement.
     38 
     39 Output
     40 
     41 Print two integers *x* and *y* — the number of bottles and towels need for the tournament.
     42 
     43 Examples
     44 
     45 Input
     46 
     47 ```
     48 5 2 3
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 20 15
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 8 2 4
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 35 32
     67 ```
     68 
     69 Note
     70 
     71 In the first example will be three rounds:
     72 
     73 1. in the first round will be two matches and for each match 5 bottles of water are needed (two for each of the participants and one for the judge),
     74 2. in the second round will be only one match, so we need another 5 bottles of water,
     75 3. in the third round will also be only one match, so we need another 5 bottles of water.
     76 
     77 So in total we need 20 bottles of water.
     78 
     79 In the second example no participant will move on to some round directly.