A8161 | Irrational problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $x$ in range $[a;b]$ with property $f(x)=x$ .
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 $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$ .
You are given function  (here  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$ .
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 $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$ .
输入格式
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$ ).
It is guaranteed that numbers $p_{1},p_{2},p_{3},p_{4}$ will be pairwise distinct.
It is guaranteed that numbers $p_{1},p_{2},p_{3},p_{4}$ will be pairwise distinct.
输出格式
Output the number of integers in the given range that have the given property.
输入输出样例
输入 #1
2 7 1 8 2 8
输出 #1
0
输入 #2
20 30 40 50 0 100
输出 #2
20
输入 #3
31 41 59 26 17 43
输出 #3
9
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted