#abc253d. D - FizzBuzz Sum Hard

D - FizzBuzz Sum Hard

Score : 400400 points

问题描述

求在 11NN(包含)之间,既不是 AA 的倍数也不是 BB 的倍数的所有整数之和。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Find the sum of integers between 11 and NN (inclusive) that are not multiples of AA or BB.

Constraints

  • 1N,A,B1091 \leq N, A,B \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN AA BB

Output

Print the answer.

Sample Input 1

10 3 5

Sample Output 1

22

The integers between 11 and 1010 (inclusive) that are not multiples of 33 or 55 are 1,2,4,71,2,4,7, and 88, whose sum is 1+2+4+7+8=221+2+4+7+8 =22.

Sample Input 2

1000000000 314 159

Sample Output 2

495273003954006262

update @ 2024/3/10 10:47:35