#SP0000200. Phân lớp nguyên tố Erdős–Selfridge
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân lớp nguyên tố Erdős–Selfridge
Classification from Erdős and Selfridge
PHOJ ID: PRIME000205
Original source: SPOJ HS12PRIM
Version: PHOJ Extended, one dataset per run.
Problem statement
Define classes of prime numbers: 2 is in class 1. For a prime , if its largest prime factor of is at most 3, then is in class 1. Otherwise its class is one plus the maximum class among the prime factors of . Given a closed interval , report the number of primes in each class 1 through 13 using the SPOJ output format.
Input
One line containing . PHOJ processes one interval per execution; the case heading is always Case 1:.
Output
Print exactly 14 lines: Case 1: followed by There are X primes in class c. for c=1,...,13.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Example
Input
2 11
Output
Case 1:
There are 4 primes in class 1.
There are 1 primes in class 2.
There are 0 primes in class 3.
There are 0 primes in class 4.
There are 0 primes in class 5.
There are 0 primes in class 6.
There are 0 primes in class 7.
There are 0 primes in class 8.
There are 0 primes in class 9.
There are 0 primes in class 10.
There are 0 primes in class 11.
There are 0 primes in class 12.
There are 0 primes in class 13.
Explanation
The primes are 2, 3, 5, 7, and 11. The first four belong to class 1, while 11 belongs to class 2 since 11−1=2×5.