QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 32 MB 總分: 100

#12984. 瓷砖

统计

Byteasar 是一位瓷砖铺设大师,他的助手 Byteolini 正在为 Byteson 一家装修浴室。浴室里需要铺设一条由各种花纹瓷砖组成的装饰性水平长条。这条长条宽 $n$ 个瓷砖,高 $1$ 个瓷砖。Byteson 夫人告诉 Byteolini,组成这条水平长条的瓷砖必须形成一个每 $k$ 个瓷砖循环一次的图案。Byteson 夫人刚走,Byteson 先生就来了,他告诉 Byteolini,组成这条水平长条的瓷砖必须形成一个每 $l$ 个瓷砖循环一次的图案。困惑的 Byteolini 来找 Byteasar 寻求建议:

“头儿,我到底该怎么铺?图案应该每 $k$ 个瓷砖循环一次,还是每 $l$ 个瓷砖循环一次?”

“管他们怎么说!你铺设的方式必须满足图案既每 $k$ 个瓷砖循环一次,又每 $l$ 个瓷砖循环一次。此外,你必须尽可能多地使用不同种类的瓷砖,以免图案过于单调。好了,别再装哲学家了,快去干活!”

Byteolini 被搞得晕头转向。请帮帮他!

任务

编写一个程序:

  • 从标准输入读取数字 $n$、$k$ 和 $l$;
  • 计算需要使用的不同瓷砖的数量;
  • 将结果写入标准输出。

输入格式

标准输入包含三个整数 $n$、$k$ 和 $l$,分别位于第一、第二和第三行。这些数字满足条件 $1 \le n \le 10^{500}$,$1 \le k,l \le n$。注意:$k$ 和 $l$ 不一定是 $n$ 的约数。

输出格式

你的程序应向标准输出写入内容。第一行且仅需一行,输出一个整数:在满足图案既每 $k$ 个瓷砖循环一次,又每 $l$ 个瓷砖循环一次的前提下,装饰长度为 $n$ 的浴室长条所能使用的最大不同瓷砖数量。

样例

输入 1

10
5
7

输出 1

2

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.