codeforces-scrape

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

807B.md (3528B)


      1 Source: https://codeforces.com/problemset/problem/807/B
      2 
      3 B. T-Shirt Hunt
      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 Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
     22 
     23 Unfortunately, you didn't manage to get into top 25, but you got into top 500, taking place *p*.
     24 
     25 Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let *s* be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed:
     26 
     27 ```
     28 i := (s div 50) mod 475  
     29 repeat 25 times:  
     30     i := (i * 96 + 42) mod 475  
     31     print (26 + i)
     32 ```
     33 
     34 Here "div" is the integer division operator, "mod" is the modulo (the remainder of division) operator.
     35 
     36 As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of *s*.
     37 
     38 You're in the lead of the elimination round of 8VC Venture Cup 2017, having *x* points. You believe that having at least *y* points in the current round will be enough for victory.
     39 
     40 To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It's difficult to do successful hacks, though.
     41 
     42 You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?
     43 
     44 Input
     45 
     46 The only line contains three integers *p*, *x* and *y* (26 ≤ *p* ≤ 500; 1 ≤ *y* ≤ *x* ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.
     47 
     48 Output
     49 
     50 Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt.
     51 
     52 It's guaranteed that your goal is achievable for any valid input data.
     53 
     54 Examples
     55 
     56 Input
     57 
     58 ```
     59 239 10880 9889
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 0
     66 ```
     67 
     68 Input
     69 
     70 ```
     71 26 7258 6123
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 2
     78 ```
     79 
     80 Input
     81 
     82 ```
     83 493 8000 8000
     84 ```
     85 
     86 Output
     87 
     88 ```
     89 24
     90 ```
     91 
     92 Input
     93 
     94 ```
     95 101 6800 6500
     96 ```
     97 
     98 Output
     99 
    100 ```
    101 0
    102 ```
    103 
    104 Input
    105 
    106 ```
    107 329 19913 19900
    108 ```
    109 
    110 Output
    111 
    112 ```
    113 8
    114 ```
    115 
    116 Note
    117 
    118 In the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places:
    119 
    120 ```
    121 475 422 84 411 453 210 157 294 146 188 420 367 29 356 398 155 102 239 91 133 365 312 449 301 343
    122 ```
    123 
    124 In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.
    125 
    126 In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.
    127 
    128 In the fourth example, it's sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.