시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 39 19 16 50.000%

문제

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

  • 겉보기에 소수: 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이다. 또, 예제는 채점하지 않는다.

W3sicHJvYmxlbV9pZCI6IjU2NDEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjODlcdWJjZjRcdWFlMzBcdWM1ZDAgXHVjMzBkXHViNDY1XHVjNzc0IFx1YzE4Y1x1YzIxOCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjZWY0XHVkNGU4XHVkMTMwIFx1YWNmY1x1ZDU1OVx1YzVkMFx1YzExYyBcdWMxOGNcdWMyMThcdWIyOTQgXHViOWU0XHVjNmIwIFx1YjJlNFx1YzU5MVx1ZDU1YyBcdWJkODRcdWM1N2NcdWM1ZDAgXHVjNzUxXHVjNmE5XHViNDFjXHViMmU0LiBcdWM3NzQgXHViYjM4XHVjODFjXHViOTdjIFx1ZDQ4MFx1YWUzMCBcdWM3MDRcdWQ1NzRcdWMxMWNcdWIyOTQgXHVjMThjXHVjMjE4XHVjNjQw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1dCBmaXRzIGluIHJlYXNvbmFibGUgc3BhY2UuJm5ic3A7PFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

ICPC > Regionals > Asia Pacific > Thailand > 2011 ACM-ICPC Asia Phuket Regional Programming Contest D번

  • 문제를 번역한 사람: baekjoon
  • 잘못된 번역을 찾은 사람: jh05013

채점 및 기타 정보

  • 예제는 채점하지 않는다.