codeforces-scrape

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

735C.md (2145B)


      1 Source: https://codeforces.com/problemset/problem/735/C
      2 
      3 C. Tennis Championship
      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 Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be *n* players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.
     22 
     23 Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.
     24 
     25 Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.
     26 
     27 Input
     28 
     29 The only line of the input contains a single integer *n* (2 ≤ *n* ≤ 1018) — the number of players to participate in the tournament.
     30 
     31 Output
     32 
     33 Print the maximum number of games in which the winner of the tournament can take part.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 1
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 3
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 2
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 4
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 2
     71 ```
     72 
     73 Input
     74 
     75 ```
     76 10
     77 ```
     78 
     79 Output
     80 
     81 ```
     82 4
     83 ```
     84 
     85 Note
     86 
     87 In all samples we consider that player number 1 is the winner.
     88 
     89 In the first sample, there would be only one game so the answer is 1.
     90 
     91 In the second sample, player 1 can consequently beat players 2 and 3.
     92 
     93 In the third sample, player 1 can't play with each other player as after he plays with players 2 and 3 he can't play against player 4, as he has 0 games played, while player 1 already played 2. Thus, the answer is 2 and to achieve we make pairs (1, 2) and (3, 4) and then clash the winners.