#CODEFORCESP7161. Irrational problem
Irrational problem
Irrational problem
题面翻译
输入p1、p2、p3、p4,输入a和b,求在[a,b]这个区间内有多少个数%p1、%p2、%p3、%p4后还是它本身
Translated by @夜刀神十香ღ
题目描述
Little Petya was given this problem for homework:
You are given function (here represents the operation of taking the remainder). His task is to count the number of integers in range with property .
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.
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 with property that probability that is not less than . In other words, Petya will pick up the number if there exist at least permutations of numbers , for which .
输入格式
First line of the input will contain 6 integers, separated by spaces: ( ).
It is guaranteed that numbers will be pairwise distinct.
输出格式
Output the number of integers in the given range that have the given property.
样例 #1
样例输入 #1
2 7 1 8 2 8
样例输出 #1
0
样例 #2
样例输入 #2
20 30 40 50 0 100
样例输出 #2
20
样例 #3
样例输入 #3
31 41 59 26 17 43
样例输出 #3
9