I Hate Number Theory
Time limit1sMemory limit128 MB
For each query interval [L, U] below one million, find the maximum of a score built from prime-factor counts over all subintervals [a, b].
- Level
Medium7 of 10
- Topics
- Number theory, Prefix sum, Dynamic programming
- Solved
- No attempts yet
Problem
After a number-theory midterm, a student who had skipped exactly one topic, Euler's totient function (), was dismayed to find every question was about it. So the student decided to define a personal totient function.
For an integer , let be the non-decreasing list of primes whose product is . For example, , , and . Let be the length of , i.e. the number of prime factors of counted with multiplicity. Thus , , and .
Now, for a positive integer , define as follows.
The table below lists the first values of .
For two positive integers , with , define the totient function as follows.
For example, , , and .
Given an interval , write a program that finds the maximum value of over all , with . For instance, over the interval the maximum is , attained at .
Input
The input consists of several test cases, at most of them. Each test case is a single line containing two integers and . ()
The last line contains two values of ; this line is not processed.
Output
For each test case, print on its own line the maximum value of obtainable over the interval . Each line has the form <test case number>. <maximum>, where the test case number is counted from .