#CCBCHBA0000018. Tổng những số chia hết k (Sum of Multiples of K)
Tổng những số chia hết k (Sum of Multiples of K)
Sum of Multiples of K
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative n and positive k, sum all integers i in [1,n] divisible by k using a for loop and a 64-bit accumulator.
Input
n k, 0<=n<=1000000 and 1<=k<=1000000.
Output
The sum as an integer.
Subtasks
- Subtask 1 (20%): , .
- Subtask 2 (30%): , .
- Subtask 3 (50%): , .
Examples
Example 1
Input
10 3
Output
18
Explanation
3+6+9=18.
Example 2
Input
0 1
Output
0
Explanation
The range is empty.