QOJ.ac

QOJ

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

#10572. ICPC Square

统计

ICPC Square 是 ICPC 委员会为参赛者提供的酒店,共有 $N$ 层(编号从 $1$ 到 $N$)。这家酒店的电梯非常独特:如果一个人当前在 $x$ 层,乘坐一次电梯可以到达 $y$ 层,当且仅当 $y$ 是 $x$ 的倍数且 $y - x \le D$。

你目前在 $S$ 层。你希望通过乘坐零次或多次电梯到达尽可能高的楼层。请确定你能到达的最高楼层。

输入格式

一行,包含三个整数 $N$、$D$ 和 $S$($2 \le N \le 10^{12}$;$1 \le D \le N - 1$;$1 \le S \le N$)。

输出格式

输出一个整数,表示通过乘坐零次或多次电梯所能到达的最高楼层。

样例

样例输入 1

64 35 3

样例输出 1

60

说明 1

首先,从 $3$ 层乘电梯到 $15$ 层。这是可能的,因为 $15$ 是 $3$ 的倍数且 $15 - 3 \le 35$。然后,从 $15$ 层乘电梯到 $30$ 层。这是可能的,因为 $30$ 是 $15$ 的倍数且 $30 - 15 \le 35$。最后,从 $30$ 层乘电梯到 $60$ 层。这是可能的,因为 $60$ 是 $30$ 的倍数且 $60 - 30 \le 35$。

样例输入 2

2024 2023 1273

样例输出 2

1273

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.