시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 18 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+XHVjZWY0XHVkNGU4XHVkMTMwIFx1YWNmY1x1ZDU1OVx1YzVkMFx1YzExYyBcdWMxOGNcdWMyMThcdWIyOTQgXHViOWU0XHVjNmIwIFx1YjJlNFx1YzU5MVx1ZDU1YyBcdWJkODRcdWM1N2NcdWM1ZDAgXHVjNzUxXHVjNmE5XHViNDFjXHViMmU0LiBcdWM3NzQgXHViYjM4XHVjODFjXHViOTdjIFx1ZDQ4MFx1YWUzMCBcdWM3MDRcdWQ1NzRcdWMxMWNcdWIyOTQgXHVjMThjXHVjMjE4XHVjNjQwIFx1YzVmMFx1YWQwMFx1YjQxYy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