All Tracks Math Number Theory Problem

A huge sum
Tag(s):

Hard, Math, Number Theory, Sieve

Problem
Editorial
Analytics

Let \(D(n)\) denote the number of divisors of n. \(D(1) = 1, D(6) = 4\).

Let \( F(N,K) = \displaystyle \sum_{i=1}^{N} D \left(i^K \right)\)

You are given T tasks. Each task contains two integers, N and K. You have to output \(F(N,K)\) modulo 10^9 + 7 for every task.

Input
First line contains a single integer T, the number of tasks.
Each of the next T lines contain two integers separated by a space, N, and K respectively.

Output
For each task, print \(F(N,K)\) modulo 10^9 + 7 on a new line .

Constraints
\(1 \leq T \leq 10^4\)
\( 1 \le N,K \le 10^7 \)

SAMPLE INPUT
2
3 1
5 2
SAMPLE OUTPUT
5
15
Explanation

In the first case, answer is \(D(1) +D(2)+D(3) = 1 + 2 + 2 = 5\).
In second case, answer is \(D(1^2)+D(2^2)+D(3^2)+D(4^2)+D(5^2) = 1 + 3 + 3 + 5 + 3 = 15\)

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 512 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

September Circuits

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?