QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB

#23958. 二选一,不可兼得

Statistics

题目描述

给定正整数 $N$、$A$、$B$。这里,$A \neq B$。

请输出在 $1$ 到 $N$(含两端)的整数中,恰好只能被 $A$ 和 $B$ 中的一个整除的整数的个数。

数据范围

  • $1 \le N \le 100$。
  • $1 \le A \le 100$。
  • $1 \le B \le 100$。
  • $A \neq B$。
  • 输入的所有值均为整数。

输入格式

输入以如下格式给出:

N
A
B

输出格式

输出在 $1$ 到 $N$(含两端)的整数中,恰好只能被 $A$ 和 $B$ 中的一个整除的整数的个数,省略单位(个)。

除答案外不要输出任何内容。(也不要输出提示输入的文字等。)

输入输出样例

输入样例 1

6
2
3

输出样例 1

3
  • $1$ 既不能被 $2$ 整除,也不能被 $3$ 整除。
  • $2$ 能被 $2$ 整除,但不能被 $3$ 整除。
  • $3$ 不能被 $2$ 整除,但能被 $3$ 整除。
  • $4$ 能被 $2$ 整除,但不能被 $3$ 整除。
  • $5$ 既不能被 $2$ 整除,也不能被 $3$ 整除。
  • $6$ 既能被 $2$ 整除,也能被 $3$ 整除。

因此,在 $1$ 到 $6$(含两端)的整数中,恰好只能被 $2$ 和 $3$ 中的一个整除的整数有 $2$、$3$、$4$ 共 $3$ 个。因此,输出 $3$。


输入样例 2

1
5
3

输出样例 2

0
  • $1$ 既不能被 $5$ 整除,也不能被 $3$ 整除。

因此,在 $1$ 到 $1$(含两端)的整数中,恰好只能被 $5$ 和 $3$ 中的一个整除的整数 $1$ 个也不存在,即有 $0$ 个。因此,输出 $0$。


输入样例 3

100
1
2

输出样例 3

50

在 $1$ 到 $100$(含两端)的整数中,恰好只能被 $1$ 和 $2$ 中的一个整除的整数是 $1$ 到 $100$(含两端)的所有奇数,共 $50$ 个。因此,输出 $50$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.