시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 19 12 5 62.500%

문제

컴퓨터 과학에서 소수는 매우 다양한 분야에 응용된다. 이 문제를 풀기 위해서는 소수와 연관된 두 가지 정의를 알아야 한다.

분명한 소수: 1보다 크고, t보다 작거나 같은 수로 나누어 떨어지지 않는 양의 정수.

분명한 쌍둥이 소수: 차이가 2인 분명한 소수 두 개.

n과 t가 주어졌을 때, n자리 분명한 쌍둥이 소수 (p와 p+2)를 구하는 프로그램을 작성하시오.

입력

입력은 최대 1001개의 줄로 이루어져 있다. 각 줄에는 두 양의 정수 n (3500 ≤ n ≤ 5000)과 t (t ≤ 8000)가 주어진다.

입력의 마지막 줄에는 0 0이 주어진다.

출력

입력의 각 줄마다 n자리 분명한 쌍둥이 소수가 p와 (p+2) 일 때, p를 출력한다. 가능한 p가 여러 가지라면, 아무거나 출력한다.

예제 입력 1

2 6
0 0

예제 출력 1

17

힌트

n ≥ 3500이지만 3500자리는 한 화면에 보이지 않기 때문에 예제만 n = 2이다. 또, 예제는 채점하지 않는다.

W3sicHJvYmxlbV9pZCI6IjU2NDEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJkODRcdWJhODVcdWQ1NWMgXHVjMzBkXHViNDY1XHVjNzc0IFx1YzE4Y1x1YzIxOCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjZWY0XHVkNGU4XHVkMTMwIFx1YWNmY1x1ZDU1OVx1YzVkMFx1YzExYyBcdWMxOGNcdWMyMThcdWIyOTQgXHViOWU0XHVjNmIwIFx1YjJlNFx1YzU5MVx1ZDU1YyBcdWJkODRcdWM1N2NcdWM1ZDAgXHVjNzUxXHVjNmE5XHViNDFjXHViMmU0LiBcdWM3NzQgXHViYjM4XHVjODFjXHViOTdjIFx1ZDQ4MFx1YWUzMCBcdWM3MDRcdWQ1NzRcdWMxMWNcdWIyOTQgXHVjMThjXHVjMjE4XHVjNjQwIFx1YzVmMFx1YWQwMFx1YjQxY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