P28509 [洛谷] Prime Pocket
普及
题目描述

Problem Description

Little A has a prime pocket, which can hold various prime numbers. Starting from 2, he sequentially checks each natural number to determine if it is a prime number. If it is, he puts the number into the pocket.

The load of the pocket is the sum of all the numbers inside it.

However, the pocket has a limited carrying capacity, and the sum of the primes it holds cannot exceed \( L \). Given \( L \), how many primes can the pocket hold? Output these primes in ascending order, followed by the maximum number of primes that can be held, with each number separated by a newline.

Input Format

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

Output Format

Output the primes in ascending order, followed by the maximum number of primes that can be held, with each number separated by a newline.

Sample Input and Output

Sample Input #1

100

Sample Output #1

2
3
5
7
11
13
17
19
23
9

Sample Input #2

5

Sample Output #2

2
3
2

Sample Input #3

11

Sample Output #3

2
3
5
3

Notes

The data guarantees that \( 1 \le L \le 10^5 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
100
样例输出
2 3 5 7 11 13 17 19 23 9