P29139 [洛谷] [POI 2020/2021 R3] Sum of Prime Numbers
提高+
题目描述

Problem Description

Given a number \( n \), find \( l \) and \( r \) such that the sum of all prime numbers in the interval \([l, r]\) equals \( n \).

If there are multiple solutions, any one of them is acceptable; if there is no solution, output NIE.

Input Format

A single line containing a positive integer \( n \).

Output Format

If there is a solution, output two positive integers \( l \) and \( r \) on a single line.

If there is no solution, output NIE.

Sample Input and Output

Sample Input #1

15

Sample Output #1

3 7

Sample Input #2

9992

Sample Output #2

4993 4999

Sample Input #3

100000000

Sample Output #3

NIE

Sample Input #4

1000000007

Sample Output #4

1000000007 1000000007

Sample Input #5

99999999996

Sample Output #5

295693 1693067

Notes

For all test cases, \( 1 \leq n \leq 10^{11} \).

Subtask Number Additional Constraints Score
1 \( n \leq 10000 \) 15
2 \( n \leq 10^8 \) 20
3 \( n \leq 2 \times 10^9 \) 40
4 25
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
15
样例输出
3 7