#GL0000253. Madoka và Trường Đại học Tốt Nhất (Madoka and The Best University)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Madoka và Trường Đại học Tốt Nhất (Madoka and The Best University)
Madoka and The Best University
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Madoka wants to study at Novosibirsk State University. During the entrance examination, she encounters a task involving three positive integers.
Given an integer , consider every ordered triple of positive integers satisfying
For each triple, first compute the greatest common divisor of and , then compute the least common multiple of that value and . Its contribution is
Here is the greatest common divisor, and is the least common multiple of two positive integers .
Calculate the sum of these contributions over all valid triples . Distinct triples are counted separately even when they contain the same values in different orders.
Input
- The only line contains an integer , the required sum of the three values in each triple.
Output
- Print one integer: the required sum modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
3
Output
1
Explanation
The only positive triple summing to is . Its greatest common divisor is ; hence its contribution is . The answer is .
Example 2
Input
5
Output
11
Explanation
There are exactly six ordered triples of positive integers with sum :
- : , hence .
- : , hence .
- : , hence .
- : , hence .
- : , hence .
- : , hence .
Their contributions sum to . Because this is less than , the printed remainder is also .
Example 3
Input
69228
Output
778304278
Explanation
Here . Every ordered positive triple whose entries sum to contributes exactly one value . Summing all contributions and taking the remainder modulo gives . Neither the individual triples nor the unreduced total are printed.