QOJ.ac

QOJ

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

#3741. 时间旅行

الإحصائيات

假设 Bobo 位于时间轴(数轴)上 $t_0$ 点,他要使用时间机器回到区间 $(0, h]$ 中。

当 Bobo 位于时间轴上 $t$ 点,同时时间机器有 $c$ 单位燃料时,他可以选择一个满足 $\lceil \frac{x}{h}\rceil \cdot h \leq c$ 的非负整数 $x$, 那么时间机器会在 $[0, x]$ 中随机整数 $y$,使 Bobo 回到 $(t - y)$ 点,同时消耗 $y$ 单位燃料。 (其中 $\lceil \cdot \rceil$ 表示上取整)

因为时间机器的随机性,对于给出的参数 $h$ 和时间机器剩余燃料 $c$,Bobo 想知道能够保证回到区间 $(0, h]$ 中的 $t_0$ 的最大值。

输入格式

输入文件包含多组数据,请处理到文件结束。

每组数据包含 $2$ 个整数 $h$ 和 $c$.

输出格式

对于每组数据输出 $1$ 个整数表示 $t_0$ 的最大值。

样例输入

100 99
100 100
100 149

样例输出

100
101
150

样例解释

对于第一组样例,因为剩余燃料 $c = 99 < 100$,Bobo 只能选择 $x = 0$,从而 $y = 0$。所以当 $t_0 > h = 100$ 时,Bobo 一定无法回到目标区间。

对于第二组样例,当 $t_0 = 102$ 时,选择 $x = 2$,可能随机到 $y = 1$,此时位于 $t = 99$,燃料 $c = 99$,任务失败。所以 $t_0 < 102$.

数据范围

  • $1 \leq h \leq 10^9$
  • $0 \leq c \leq 10^9$
  • 数据组数不超过 $10^5$.
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.