#P5723. 【深基4.例13】质数口袋

【深基4.例13】质数口袋

Problem Description

Little A has a prime pocket that can hold prime numbers. Starting from 22, he checks each natural number in order to see whether it is prime. If it is prime, he puts that number into the pocket.

The load of the pocket is the sum of all numbers in the pocket.

However, the pocket has a limited capacity: the sum of the primes put in cannot exceed LL. Given LL, how many primes can the pocket hold at most? Output these primes from small to large, and then output the maximum number of primes that can be held. Separate numbers with newline characters.

Input Format

One line containing one positive integer LL.

Output Format

Output these primes from small to large, and then output the maximum number of primes that can be held.

100
2
3
5
7
11
13
17
19
23
9
5
2
3
2
11
2
3
5
3

Hint

Constraints: 1L1051 \le L \le {10}^5.

Translated by ChatGPT 5