#GL0000254. Tổng Bội Chung Nhỏ Nhất (LCM Rush)
Bài tập thuộc lộ trình
Mục lục đề ⌄
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 and , denoted by , is the smallest positive integer divisible by both and .
You are given two positive integers and . For each integer from through , calculate the least common multiple of and , and add all these values.
Find the remainder of
upon division by . 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 and . The value is the upper bound on index , and is used in every least-common-multiple calculation.
Output
- Print one integer on one line: .
Subtasks
- Subtask 1 (10 points): ; .
- Subtask 2 (15 points): ; .
- Subtask 3 (25 points): ; .
- Subtask 4 (50 points): ; .
Examples
Example 1
Input
4 2
Output
14
Explanation
For and , the four least common multiples are . Their sum is , so the printed result is 14.
Example 2
Input
10000 100
Output
865504986
Explanation
For and , consider every from to . For instance, , , and . The sum of all contributions modulo is 865504986.
Example 3
Input
1000000000 90
Output
50001213
Explanation
For and , the contributions from are . Continuing through , then taking the result modulo , yields 50001213. These first few terms alone do not determine the answer.
Example 4
Input
1000000000 999999900
Output
231285006
Explanation
For and , both and contribute , since is divisible by . Summing all terms and reducing modulo yields 231285006. This example exercises a large value of .