시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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
W3sicHJvYmxlbV9pZCI6IjQwNDQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIzYzRcdWM4MDQgMjQiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YjNjNFx1YzgwNCAyNFx1YjI5NCBcdWNkMDhcdWI0ZjFcdWQ1NTlcdWMwZGRcdWI0ZTRcdWM3N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