Two Arithmetic Progressions

2020 VietMX 0

You are given two arithmetic progressions: a 1 k + b 1 and a 2 l + b 2. Find the number of integers x such that L ≤ x ≤ R and x = a 1 k‘ + b 1 = a 2 l‘ + b 2, for some integers k‘, l‘ ≥ 0. Input The only line contains six integers a 1, b 1, a 2, b 2, L, R (0 < a 1, a 2 ≤ 2·109,  - 2·109 ≤ b 1, b 2, L, R ≤ 2·109, L ≤ R). Output Print the […]