No Girls One Sequence

4.4

11 votes
Mathematics, Medium, Greatest common divisor, Number Theory
Problem

The score of a sequence that contains positive integers b1,b2,,bk is given as gcd(b1,b2,,bk).

You are provided a sequence of positive integers a1,a2,,an and two integers l and r (lr). You are required to select an integer x (lxr) and add x to all elements of the a. This provides you a new sequence of positive integersa1+x,a2+x,,an+x.

If you have selected the x through an optimal way, then determine the maximum score of a1+x, a2+x, ,an+x?

Input format

  • First line: Three integers n, l, and r representing the number of elements available in the a sequence and the allowed range of x (1n106, 1lr1012)
  • Second line: a1,a2,,an (1ai1012)

Output format

Print an integer that represents the maximum score of a1+x,a2+x,,an+x.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

by choosing x=1 the sequence will be [2,4] which has score 2. By choosing x=2 the sequence will be [3,5] which has score 1. So we choose x=1.

Editor Image

?