Largest remainder
Time limit1sMemory limit1024 MB
Given N huge positive integers (up to 50 digits), find the maximum value of a_i mod a_j over all ordered pairs i, j. The sequence has at least two distinct values.
- Level
Medium6 of 10
- Topics
- Sorting, Math, Greedy, Implementation
- Solved
- No attempts yet
Problem
A sequence of positive integers is given. The sequence contains at least one pair of values that differ. Write a program max that finds the largest value of the remainder when is divided by , where and each take every value from 1 to .
Input
The first line contains . The second line contains , separated by spaces.
Output
Output one integer, the largest remainder sought.
Constraints
- , .