#GL0000372. Tổng bội chung nhỏ nhất – bản khó (LCM Sum (Hard Version))
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tổng bội chung nhỏ nhất – bản khó (LCM Sum (Hard Version))
LCM Sum (Hard Version)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given independent range queries. Each query specifies . Count the strictly increasing triples satisfying
$$l\le i<j<k\le r,\qquad \operatorname{lcm}(i,j,k)\ge i+j+k.$$Here, is the least common multiple of three integers. The ordering ensures that every distinct triple is counted exactly once.
An answer may exceed the 32-bit integer range; use 64-bit arithmetic. Queries do not modify any data; output their answers in input order.
Input
The first line contains . Each of the next lines contains . A single input file contains one batch of queries, allowing offline processing.
Output
Print lines, the number of valid triples for each query, in order.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Example 1
Input
5
1 4
3 5
8 86
68 86
6 86868
Output
3
1
78975
969
109229059713337
Explanation
For , the four triples are , , , and . Only is invalid, since its LCM is . For , the only triple is , and its LCM is .