QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#12984. Tiles

الإحصائيات

Byteasar, a master tiler, and his mate Byteolini renovate a bathroom of the Bytesons. There is to be a decorative, horizontal strip composed of various figured tiles in the bathroom. The strip is to be $n$ tiles wide and one tile high. Mrs Byteson has told Byteolini that the tiles composing the horizontal strip have had to be put to form a pattern recurring every $k$ tiles. As soon as Mrs Byteson has left, Mr Byteson has come and has told Byteolini that the tiles composing the horizontal strip have had to be put to form a pattern recurring every $l$ tiles. Confused Byteolini has come to Byteasar to ask for advice:

"Chief, how should I finally tile? Should the pattern recur every $k$, or every $l$ tiles?"

"Whatever they say! You have to tile in such a way that the pattern recurs both every $k$ and every $l$ tiles. Moreover you have to use as many different tiles as possible, to make the pattern not too monotonous. Now, stop playing the philosopher and go to work!"

Byteolini has been left completely dizzy. Help him!

Task

Write a program which:

  • reads the numbers $n$, $k$ and $l$ from the standard input,
  • computes the number of different tiles that are to be used,
  • writes the result to the standard output.

Input

In the standard input there are three integers $n$, $k$ and $l$ - in the first, second and third line, accordingly. The numbers satisfy the conditions $1 \le n \le 10^{500}$, $1 \le k,l \le n$. Note: the numbers $k$ and $l$ need not be divisors of $n$.

Output

Your program should write to the standard output. In the first and only line there should be one integer: the maximal number of different tiles to use to decorate the bathroom with a strip of length n in such a way that the pattern recurs both every $k$ and every $l$ tiles.

Example

Input

10
5
7

Output

2
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.