Product of GCDs
Time limit5sMemory limit512 MB
Compute the product of gcd(i, j) over all pairs 1<=i<=N, 1<=j<=M, modulo 1e9+7, with N and M up to 15 million.
- Level
Hard8 of 10
- Topics
- Number theory, Math, Combinatorics, Prefix sum
- Solved
- No attempts yet
Problem
You are given and . Write a program that computes the product of over every from to and every from to .
Input
The first line contains and , separated by a space. ()
Output
Print the product modulo on the first line.