PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000112. In một số nguyên tố theo chu kỳ 500 (Printing some primes — Hard)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
In một số nguyên tố theo chu kỳ 500 (Printing some primes — Hard)
Printing some primes (Hard)
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Consider all prime numbers smaller than sorted in increasing order as , where .
Print only those whose 1-based positions are . Equivalently, print if and only if . Print each chosen prime on its own line in increasing order.
Input
There is no input.
Output
Print every selected prime, one per line, with no index or other text.
Subtasks
- Subtask 1 (100 points): Consider all primes ; output exactly the indices satisfying .
Examples
Input
Output (excerpt, not the complete output)
2
3581
7927
...
999978527
999988747
999999151
Explanation
The first prime is , the -st is , and the -st is . Keep every -th prime after the first. The ... line is a placeholder in this illustrative excerpt only; the submitted program must print all selected primes and must never print the ellipsis.