#SP0000059. Cắt phần giữa danh sách nguyên tố (Prime Cuts)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cắt phần giữa danh sách nguyên tố (Prime Cuts)
Prime Cuts
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Build the ascending list containing and every prime not greater than . Following the original statement’s convention, is included in this list, even though is not prime in modern mathematics. Let be the number of entries. If is even, select the central consecutive entries; if is odd, select the central entries. If this number exceeds , use the whole list. Print the selected entries in ascending order.
Input
One line contains integers and .
Output
Print a line formatted as N C: followed by the selected entries, each preceded by exactly one space. Print one additional blank line after the result.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
21 2
Output
21 2: 5 7 11
Explanation
The list through is , so . Since is odd and , take central entries. Removing the first and last three gives . Print 21 2: 5 7 11, followed by a blank line.