QOJ.ac

QOJ

時間限制: 8 s 記憶體限制: 256 MB 總分: 100

#8203. Sum of prime numbers

统计

A natural number $n$ that has exactly two distinct divisors, 1 and $n$, is called a prime number. For example, 6 is not a prime number (as it is divisible by 2), 1 is not a prime number (as it has only one divisor, 1), but 2 and 7 are prime numbers.

Bajtazar is very fond of prime numbers. He has written down a sequence of consecutive prime numbers on a piece of paper: $2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 \dots$

He would like to choose a contiguous fragment from this sequence whose sum is equal to his favorite number $N$. Help him and write a program that, for a given number $N$, finds any contiguous interval in the sequence of prime numbers whose sum is exactly $N$.

Input

The first and only line of input contains a single natural number $N$ ($1 \le N \le 10^{11}$) representing the sum expected by Bajtazar.

Output

The first and only line of output should contain two prime numbers $L$ and $R$ ($1 \le L \le R \le N$) such that the sum of prime numbers in the closed interval $[L, R]$ is exactly $N$.

If there are multiple solutions, your program may output any one of them. If no solution exists, you should output only the single word NIE.

Evaluation tests

  • Test 1: $N = 9992$; output: $4993\ 4999$
  • Test 2: $N = 10^8$; output: NIE
  • Test 3: $N = 10^9 + 7$; output: $10^9 + 7\ 10^9 + 7$
  • Test 4: $N = 10^{11} - 4$; output: $295693\ 1693067$

Examples

Input 1

15

Output 1

3 7

Subtasks

The test set is divided into the following subtasks. Tests for each subtask consist of one or more separate test groups.

Subtask Constraints Points
1 $N \le 10\,000$ 15
2 $N \le 10^8$ 20
3 $N \le 2 \cdot 10^9$ 40
4 no additional constraints 25

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.