CF710D.Two Arithmetic Progressions

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two arithmetic progressions: a1k+b1a_{1}k+b_{1} and a2l+b2a_{2}l+b_{2} . Find the number of integers xx such that L<=x<=RL<=x<=R and x=a1k+b1=a2l+b2x=a_{1}k'+b_{1}=a_{2}l'+b_{2} , for some integers k,l>=0k',l'>=0 .

输入格式

The only line contains six integers a1,b1,a2,b2,L,R(0<a1,a22×109,2×109b1,b2,L,R2×109,LR)a_{1},b_{1},a_{2},b_{2},L,R \, ( 0 \lt a_1,a_2 \le 2\times10^9,-2\times10^9 \le b_1,b_2,L,R \le 2\times10^9,L \le R) .

输出格式

Print the desired number of integers xx .

输入输出样例

  • 输入#1

    2 0 3 3 5 21
    

    输出#1

    3
    
  • 输入#2

    2 4 3 0 6 17
    

    输出#2

    2
    
首页