PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000200. Phân lớp nguyên tố Erdős–Selfridge

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 p>2p>2, if its largest prime factor of p−1p-1 is at most 3, then pp is in class 1. Otherwise its class is one plus the maximum class among the prime factors of p−1p-1. Given a closed interval [a,b][a,b], report the number of primes in each class 1 through 13 using the SPOJ output format.

Input

One line containing a,ba,b. 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): 0≤a≤b≤1040\le a\le b\le10^4.
  • Subtask 2 (30 points): 0≤a≤b≤1060\le a\le b\le10^6.
  • Subtask 3 (50 points): 0≤a≤b≤5⋅1070\le a\le b\le5\cdot10^7.

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.