#CCBCHBON0000021. Bỏ bội của cả 2 và 3 (Skip Multiples of Both Two and Three)
Bỏ bội của cả 2 và 3 (Skip Multiples of Both Two and Three)
Skip Multiples of Both Two and Three
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
For nonnegative , sum the integers from 1 through that are not divisible by both 2 and 3. Equivalently, skip multiples of 6; integers divisible by only one of 2 or 3 must still be included. Print 0 when .
Input
One integer .
Output
Print the sum as a 64-bit integer.
Subtasks
-
Subtask 1 (20%): .
-
Subtask 2 (30%): .
-
Subtask 3 (50%): .
Examples
Example 1
Input:
7
Output:
22
Explanation:
Sum 1 through 7, excluding multiples of 6, obtaining 22.
Example 2
Input:
0
Output:
0
Explanation:
Sum 1 through 0, excluding multiples of 6, obtaining 0.