Skip to main content
Back to problems
Codeforces
Medium
Math
Combinatorics
Number Theory
The Intriguing Obsession

Count the number of valid pairs of integers satisfying a divisibility-based condition, modulo a large prime.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

You are given multiple test cases. For each test case, count how many ordered pairs of positive integers satisfy the problem's divisibility condition for the given parameter values. Since the answer can be very large, output it modulo 109+710^9+7.

The key challenge is to derive a counting formula rather than enumerate pairs directly.

Input Format

  • The first line contains an integer tt — the number of test cases.
  • Each test case contains the integers needed to define the counting task.
  • Process each test case independently.

Output Format

For each test case, print a single integer — the number of valid pairs modulo 109+710^9+7.

Constraints

  • 1t1 \le t is small enough to allow per-testcase math-based processing.
  • Values are large enough that brute force enumeration is not feasible.
  • Answers are taken modulo 109+710^9+7.
Examples
Sample cases returned by the problem API.

Example 1

Input

1
2 3

Output

6

Explanation

This illustrative example shows a case where the count can be computed from a direct formula rather than enumeration.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.