Number Theory and Applications: Recitation
Time limit4sMemory limit512 MB
Given n up to 1e9 and v up to 100, compute the sum over i=1..n and u=1..v of Jordan's totient function modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Number theory, Math, Prefix sum, Binary search
- Solved
- No attempts yet
Problem
Cheongeung, who became a teaching assistant for Number Theory and Applications, was too busy to prepare a recitation problem. Knowing that the students learned the Euler's totient function () in this week's class, he was about to fall back on handing out many problems that ask for given some .
\begin{equation*} \varphi(n)=\left|\left{k\in\mathbb{N}:::k\leq n,:\gcd(k,n)=1\right}\right| \end{equation*}
However, he realized that for this problem the formula is too well known once you factorize, so it would not fill up the whole recitation hour. So he prepared a problem that asks for the Jordan's totient function, a generalization of the Euler's totient function.
\begin{equation*} \varphi(n,v)=\left|\left{(k_1,k_2,\cdots,k_v)\in\mathbb{N}^v:::\forall i,:k_i\leq n,:\gcd(k_1,k_2,\cdots,k_v,n)=1\right}\right| \end{equation*}
But he fell into worry that this problem would also be solved too easily. While thinking of a harder problem, he recalled a famous anecdote about Gauss.
"When Gauss was young, his teacher Büttner told him to find the sum of the numbers from to , and Gauss was the fastest to give the answer ."
Inspired by this, he made the problem ask for . Now solving this problem is up to you. Given and , write a program that finds .
Input
The input is given on a single line, containing two positive integers and . The input satisfies and .
Output
Print . The answer can become very large, so print it modulo .