Irrationa problem

Time Limit: 2000MS Memory Limit: 262144K 64bit IO Format: %I64d& %I64

Description

Little Petya was given this problem for homework:

You are given function Irrational <wbr>problem (here Irrational <wbr>problem represents the operationof taking the remainder). His task is to count the number ofintegers x inrange [a;b] withproperty f(x) = x.

It is a pity that Petya forgot the order in which the remaindersshould be taken and wrote down only 4 numbers. Each of 24 possibleorders of taking the remainder has equal probability of beingchosen. For example, if Petya has numbers 1, 2, 3, 4 then he cantake remainders in that order or first take remainder modulo 4,then modulo 2, 3, 1. There also are 22 other permutations of thesenumbers that represent orders in which remainder can be taken. Inthis problem 4 numbers wrote down by Petya will be pairwisedistinct.

Now it is impossible for Petya to complete the task given byteacher but just for fun he decided to find the number ofintegers Irrational <wbr>problem with property thatprobability thatf(x) = x isnot less than 31.4159265352718281828459045%. In otherwords, Petya will pick up the number x if there existat least 7 permutations ofnumbersp1, p2, p3, p4, forwhich f(x) = x.

Input

First line of the input will contain 6 integers, separated byspaces: p1, p2, p3, p4, a, b (1 ≤ p1, p2, p3, p4 ≤ 1000, 0 ≤ a ≤ b ≤ 31415).

It is guaranteed that numbers p1, p2, p3, p4 will be pairwisedistinct.

Output

Output the number of integers in the given range that have thegiven property.

Sample Input

Input
2 7 1 8 2 8

Output
0

Input
20 30 40 50 0 100

Output
20

Input
31 41 59 26 17 43

Output
9

[Submit [GoBack  [Status]

#include<iostream>
using namespace std;
int main()
{
     int a,b,p1,p2,p3,p4,count;
         while(cin>>p1>>p2>>p3>>p4>>a>>b)
         {
                 count=0;
                 for(int i=a;i<=b;i++)
                         if((((i%p1)%p2)%p3)%p4==i)
                               count++;

                         cout<<count<<endl;
         }
  return 0;
                

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值