#B4272. Maximum Number of Prime Factors

    ID: 11929 Type: Default 1000ms 256MiB

Maximum Number of Prime Factors

Maximum Number of Prime Factors

Given two positive integers \(N\) and \(M\) (\(1\leq N\leq M\leq 10^7\)), count the total number of prime factors (including multiplicities) for each integer in the range \([N, M]\), and output the maximum count among them.

For example, when \(N = 6\) and \(M = 10\), the factorization is as follows:

  • \(6 = 2 \times 3\) → 2 prime factors
  • \(7 = 7\) → 1 prime factor
  • \(8 = 2 \times 2 \times 2\) → 3 prime factors
  • \(9 = 3 \times 3\) → 2 prime factors
  • \(10 = 2 \times 5\) → 2 prime factors

The maximum count is \(3\), so the output should be 3.

inputFormat

The input consists of two space-separated positive integers \(N\) and \(M\).

outputFormat

Output a single integer, which is the maximum number of prime factors (with multiplicity) among all numbers in the interval \([N, M]\).

sample

6 10
3