codeforces-scrape

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

68A.md (2134B)


      1 Source: https://codeforces.com/problemset/problem/68/A
      2 
      3 A. Irrational problem
      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 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Little Petya was given this problem for homework:
     22 
     23 You are given function ![](https://espresso.codeforces.com/22d161d4a5bc6cfd41667ca591d56973abfe8655.png) (here ![](https://espresso.codeforces.com/e91a39ad64cd7a33e8f1b67cd60e5b40257de950.png) represents the operation of taking the remainder). His task is to count the number of integers *x* in range [*a*;*b*] with property *f*(*x*) = *x*.
     24 
     25 It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.
     26 
     27 Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers ![](https://espresso.codeforces.com/66564024af56fb327f06ed6542f6badc5c851715.png) with property that probability that *f*(*x*) = *x* is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number *x* if there exist at least 7 permutations of numbers *p*1, *p*2, *p*3, *p*4, for which *f*(*x*) = *x*.
     28 
     29 Input
     30 
     31 First line of the input will contain 6 integers, separated by spaces: *p*1, *p*2, *p*3, *p*4, *a*, *b* (1 ≤ *p*1, *p*2, *p*3, *p*4 ≤ 1000, 0 ≤ *a* ≤ *b* ≤ 31415).
     32 
     33 It is guaranteed that numbers *p*1, *p*2, *p*3, *p*4 will be pairwise distinct.
     34 
     35 Output
     36 
     37 Output the number of integers in the given range that have the given property.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 2 7 1 8 2 8
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 0
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 20 30 40 50 0 100
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 20
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 31 41 59 26 17 43
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 9
     75 ```