PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000254. Tổng Bội Chung Nhỏ Nhất (LCM Rush)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng Bội Chung Nhỏ Nhất (LCM Rush)

LCM Rush

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

The least common multiple of two positive integers aa and bb, denoted by lcm⁡(a,b)\operatorname{lcm}(a,b), is the smallest positive integer divisible by both aa and bb.

You are given two positive integers NN and KK. For each integer ii from 11 through NN, calculate the least common multiple of ii and KK, and add all these values.

Find the remainder of

S=∑i=1Nlcm⁡(i,K)S=\sum_{i=1}^{N}\operatorname{lcm}(i,K)

upon division by 10000000071000000007. The original sum can exceed the range of ordinary integer types; only its remainder is required.

Input

  • The only line contains two space-separated positive integers NN and KK. The value NN is the upper bound on index ii, and KK is used in every least-common-multiple calculation.

Output

  • Print one integer on one line: S mod 1000000007S\bmod 1000000007.

Subtasks

  • Subtask 1 (10 points): 1≤N≤1001\le N\le 100; 1≤K≤1001\le K\le 100.
  • Subtask 2 (15 points): 1≤N≤10 0001\le N\le 10\,000; 1≤K≤1001\le K\le 100.
  • Subtask 3 (25 points): 1≤N≤1 000 000 0001\le N\le 1\,000\,000\,000; 1≤K≤1001\le K\le 100.
  • Subtask 4 (50 points): 1≤N≤1 000 000 0001\le N\le 1\,000\,000\,000; 1≤K≤1 000 000 0001\le K\le 1\,000\,000\,000.

Examples

Example 1

Input

4 2

Output

14

Explanation

For N=4N=4 and K=2K=2, the four least common multiples are 2,2,6,42,2,6,4. Their sum is 2+2+6+4=142+2+6+4=14, so the printed result is 14.

Example 2

Input

10000 100

Output

865504986

Explanation

For N=10000N=10000 and K=100K=100, consider every ii from 11 to 1000010000. For instance, lcm⁡(1,100)=100\operatorname{lcm}(1,100)=100, lcm⁡(2,100)=100\operatorname{lcm}(2,100)=100, and lcm⁡(3,100)=300\operatorname{lcm}(3,100)=300. The sum of all 1000010000 contributions modulo 10000000071000000007 is 865504986.

Example 3

Input

1000000000 90

Output

50001213

Explanation

For N=109N=10^9 and K=90K=90, the contributions from i=1,2,3i=1,2,3 are 90,90,9090,90,90. Continuing through i=109i=10^9, then taking the result modulo 10000000071000000007, yields 50001213. These first few terms alone do not determine the answer.

Example 4

Input

1000000000 999999900

Output

231285006

Explanation

For N=109N=10^9 and K=999999900K=999999900, both i=1i=1 and i=2i=2 contribute 999999900999999900, since KK is divisible by 22. Summing all 10910^9 terms and reducing modulo 10000000071000000007 yields 231285006. This example exercises a large value of KK.