PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000116. Biểu diễn bằng nhiều số nguyên tố nhất (Bachgold Problem)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Biểu diễn bằng nhiều số nguyên tố nhất (Bachgold Problem)
Bachgold Problem
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , represent it as a sum of prime numbers. Repeated prime numbers are allowed. Among all such representations, maximize the number of summands.
A prime is an integer greater than with exactly two positive divisors. The summands may appear in any order.
Input
One line containing integer .
Output
Print the maximum number of summands on the first line. On the second line print exactly primes whose sum is .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
5
Output
2
2 3
Explanation
For , we have , which uses two primes. Three primes would sum to at least . Hence the maximum number of summands is , followed by 2 3.