QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB

#23958. Either, but Not Both

Statistiques

Problem

You are given positive integers $N$, $A$, $B$. Here, $A \neq B$.

Output the number of integers between $1$ and $N$, inclusive, that are divisible by either $A$ or $B$, but not both.

Constraints

  • $1 \le N \le 100$.
  • $1 \le A \le 100$.
  • $1 \le B \le 100$.
  • $A \neq B$.
  • All input values are integers.

Input

The input is given in the following format:

N
A
B

Output

Output the number of integers between $1$ and $N$, inclusive, that are divisible by either $A$ or $B$, but not both, omitting the unit.

Do not output anything other than the answer. (Do not output sentences prompting for input, etc.)

Sample Input and Output

Sample Input 1

6
2
3

Sample Output 1

3
  • $1$ is divisible by neither $2$ nor $3$.
  • $2$ is divisible by $2$, but not divisible by $3$.
  • $3$ is not divisible by $2$, but is divisible by $3$.
  • $4$ is divisible by $2$, but not divisible by $3$.
  • $5$ is divisible by neither $2$ nor $3$.
  • $6$ is divisible by both $2$ and $3$.

Thus, among the integers between $1$ and $6$, inclusive, there are $3$ integers that are divisible by either $2$ or $3$, but not both: $2$, $3$, and $4$. Therefore, output $3$.


Sample Input 2

1
5
3

Sample Output 2

0
  • $1$ is divisible by neither $5$ nor $3$.

Thus, among the integers between $1$ and $1$, inclusive, there is not even $1$ integer divisible by either $5$ or $3$, but not both; that is, there are $0$ such integers. Therefore, output $0$.


Sample Input 3

100
1
2

Sample Output 3

50

Among the integers between $1$ and $100$, inclusive, the integers divisible by either $1$ or $2$, but not both, are all the $50$ odd numbers between $1$ and $100$, inclusive. Therefore, output $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.