Primes
Time limit8sMemory limit256 MB
Answer online queries that ask for the sum of shared distinct prime counts over all pairs in a range [a, b] up to 10^6.
- Level
Hard8 of 10
- Topics
- Number theory, Prefix sum, Math, Implementation
- Solved
- No attempts yet
Problem
This is an interactive problem.
For two positive integers , define as the number of distinct primes that divide both and . For example, , , and .
For two positive integers with , define as the sum of over all pairs of integers satisfying .
Your task is to compute for many query pairs . All queries must be answered online.
Input
The first line contains a single integer (), the number of queries. The next lines describe the queries. The -th of these lines contains two integers ().
The -th query () is available in the input only after you output the answer to the -th query.
Output
Print exactly lines. The -th line must contain the value .
Flush the output after answering each query.