PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000194. Dãy nguyên tố cách đều (Determinate Prime)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Dãy nguyên tố cách đều (Determinate Prime)
Determinate Prime
Phuoc Hung OJ ID: PRIME000199
Original source: UVa 10650
Problem statement
A run of at least three consecutive primes is equally spaced if all neighboring differences are equal. Print all maximal runs fully contained in the given interval. Do not print proper subruns of a longer run.
Input
Two non-negative integers .
Output
Print each maximal run of at least three consecutive primes in arithmetic progression, provided the entire run lies in . One run per line; print nothing if none.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Both interval endpoints are at most .
Example
Input
1 100
Output
3 5 7
47 53 59
Explanation: The runs and have constant gaps and , respectively; both are maximal and fully inside the interval.