PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000065. Liệt kê nguyên tố theo chỉ số (Enumerate Primes)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Liệt kê nguyên tố theo chỉ số (Enumerate Primes)
Enumerate Primes
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Let be the increasing sequence of primes, indexed from . Given , let be the number of primes at most . Select the primes whose indices are , keeping only values no greater than . Let be their count. Print and the chosen primes in order.
Input
One line contains three integers in that order.
Output
Print and on the first line. On the second line print the selected primes separated by spaces; print an empty second line if .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
100 3 1
Output
25 8
3 11 19 31 43 59 71 83
Explanation
There are primes at most . With , the selected zero-based indices are , yielding . Thus and .