Preparando MOJI

Two Arithmetic Progressions

1000ms 262144K

Description:

You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R and x = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0.

Input:

The only line contains six integers a1, b1, a2, b2, L, R (0 < a1, a2 ≤ 2·109,  - 2·109 ≤ b1, b2, L, R ≤ 2·109, L ≤ R).

Output:

Print the desired number of integers x.

Sample Input:

2 0 3 3 5 21

Sample Output:

3

Sample Input:

2 4 3 0 6 17

Sample Output:

2

Informação

Codeforces

Provedor Codeforces

Código CF710D

Tags

mathnumber theory

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:08:47

Relacionados

Nada ainda