PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000127. Tổng các số dư (Sum of Remainders)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng các số dư (Sum of Remainders)
Sum of Remainders
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , compute , modulo . Here is the remainder on division by .
Input
One line with two integers .
Output
Print .
Subtasks
- Subtask 1 (10 points): .
- Subtask 2 (20 points): .
- Subtask 3 (30 points): .
- Subtask 4 (40 points): (full original limits).
Examples
Example 1
Input
3 4
Output
4
Explanation: are ; their sum is .
Example 2
Input
4 4
Output
1
Explanation: The remainders sum to .
Example 3
Input
1 1
Output
0
Explanation: .