QOJ.ac

QOJ

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

#23958. Either, but Not Both

Statistiques

問題文

正整数 N,A,B が与えられる.ここで,A ≠ B である.

1 以上 N 以下の整数のうち,A と B のいずれか片方のみで割り切れるものの個数を出力せよ.

制約

  • 1 ≦ N ≦ 100.
  • 1 ≦ A ≦ 100.
  • 1 ≦ B ≦ 100.
  • A ≠ 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.