Find the smallest frequency from L to H that divides or is a multiple of every given frequency, else print NO.
Hard8Number theoryNo attempts yetTime limit10sMemory limit512 MBJeff plays in an orchestra. Each of the other N players has already fixed the sound they will play, and every player plays exactly one sound. Two sounds are in harmony when the frequency of one of them divides the frequency of the other. Harmony is that strict, so the other players are often not in harmony with each other. Jeff wants his own sound to be in harmony with the sound of every other player.
All frequencies are positive integers, so playing frequency 1, or the least common multiple of all the other frequencies, would satisfy the condition. Jeff's instrument, though, can only play frequencies between L and H. Decide whether some frequency in that range works, and if one does, find the smallest such frequency.
The first line contains the number of test cases T. Then T test cases follow, and each test case is given on two lines.
The first line contains three integers N, L, H separated by spaces. N is the number of players other than Jeff, and L and H are the lowest and the highest frequency Jeff's instrument can play. The second line contains the N frequencies played by the other players, separated by spaces.
For each test case, print one line in the form Case #x: y. Here x is the test case number starting from 1. If no frequency in the range works, print NO in place of y. Otherwise print the smallest frequency that works.