시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 29 2 2 66.667%

문제

도전 24는 초등학생들이 주로 하는 수학 게임이다. 이 게임을 시작할 때, 각 참가자는 양의 정수 i1, i2, i3, i4가 쓰여 있는 4장의 카드를 받는다. 그 다음, 사칙연산과 모든 숫자를 적절히 조합해서 24를 만드는 사람이 이긴다. 각 숫자는 모두 한 번씩 사용해야 한다. 나눗셈은 나누어 떨어질 때만 사용할 수 있다. (6/2는 되지만, 6/4는 안된다) 예를 들어, 7, 2, 5, 1을 받았을 때, 24를 만들 수 있는 방법은 (7-2)*5-1, (7+1)*(5-2)가 있다.

창영이는 도전 24와 규칙은 비슷하지만 목표가  조금 다른 게임을 하려고 한다. 수 4개가 주어졌을 때, 만들 수 있는 수를 모두 찾아보려고 한다. 그리고 나서, 연속하는 가장 긴 구간을 찾으려고 한다. 예를 들어, 7, 2, 5, 1인 경우에는 -18부터 26까지가 가장 긴 구간이다. +와 -를 사용해서, 어떤 수를 음수로 만들 수는 없다. 즉, 이항 연산자로만 사용할 수 있다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄에 수 4개가 주어진다. 수는 모두 양의 정수이고, 100을 넘지 않는다. 그리고, 중복되지 않는다.

출력

각 테스트 케이스에 대해서, 케이스 번호와 가장 긴 구간을 아래 예제 출력 형식처럼 출력한다. 만약 가장 긴 연속 구간이 여러개일 경우에는 구간의 시작 값이 가장 큰 것을 출력한다.

예제 입력 1

7 2 5 1
8 15 38 3
0 0 0 0

예제 출력 1

Case 1: -18 to 26
Case 2: 150 to 153
W3sicHJvYmxlbV9pZCI6IjQwNDQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIzYzRcdWM4MDQgMjQiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YjNjNFx1YzgwNCAyNFx1YjI5NCBcdWNkMDhcdWI0ZjFcdWQ1NTlcdWMwZGRcdWI0ZTRcdWM3Nz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