QOJ.ac

QOJ

Limite de temps : 20 s Limite de mémoire : 1024 MB Points totaux : 19

#12431. 递增的煎饼屋

Statistiques

每天早晨,Incremental House of Pancakes 的厨房员工都会准备好当天所有的煎饼,并将它们分成两堆。最初,左侧的堆有 $L$ 个煎饼,右侧的堆有 $R$ 个煎饼。

这家餐厅的顾客行为非常一致:第 $i$ 位到达的顾客(从 1 开始计数)总是点 $i$ 个煎饼。当第 $i$ 位顾客下单点 $i$ 个煎饼时,你会从剩余煎饼较多的那一堆中取出 $i$ 个煎饼(如果两堆数量相同,则从左侧的堆中取出)。如果两堆中都没有至少 $i$ 个煎饼,餐厅就会打烊,第 $i$ 位顾客将无法获得任何煎饼。你永远不会通过从两堆中各取一部分来完成订单。

给定每堆煎饼的初始数量,你需要计算会有多少位顾客得到服务,以及当餐厅打烊时,每堆中各剩下多少个煎饼。

输入格式

输入的第一行给出了测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例包含一行,其中有两个整数 $L$ 和 $R$:如上所述,左侧和右侧堆中煎饼的初始数量。

输出格式

对于每个测试用例,输出一行 Case #x: n l r,其中 $x$ 是测试用例编号(从 1 开始),$n$ 是得到服务的顾客数量,$l$ 和 $r$ 分别是餐厅打烊时左侧和右侧堆中剩余的煎饼数量。

数据范围

$1 \le T \le 1000$。

测试集 1(可见判定)

$1 \le L \le 1000$ $1 \le R \le 1000$

测试集 2(隐藏判定)

$1 \le L \le 10^{18}$ $1 \le R \le 10^{18}$

样例

输入 1

3
1 2
2 2
8 11

输出 1

Case #1: 1 1 1
Case #2: 2 1 0
Case #3: 5 0 4

说明

在样例 1 中,第一位顾客从右侧堆中获得了 1 个煎饼,使得每堆各剩下 1 个煎饼。第二位顾客想要 2 个煎饼,但此时没有哪一堆有足够的煎饼,尽管总共还有 2 个煎饼。

在样例 2 中,第一位顾客从左侧堆中获得了 1 个煎饼,因为两堆数量相同。这使得左侧堆剩下 1 个煎饼,右侧堆剩下 2 个煎饼。第二位顾客想要 2 个煎饼,你从右侧堆中为他们提供,将其清空。当第三位顾客到达时,没有哪一堆有 3 个煎饼,因此不再满足任何订单。

在样例 3 中,第一位顾客从右侧堆中获得服务,左侧堆剩下 8 个煎饼,右侧堆剩下 10 个煎饼。第二位顾客也从右侧堆中获得服务,使得两堆各剩下 8 个煎饼。第三位顾客从左侧堆中获得服务,左侧剩下 5 个煎饼,右侧剩下 8 个煎饼。第四位顾客从右侧堆中获得服务,右侧剩下 4 个煎饼。为第五位顾客服务后,左侧堆被清空,此时两堆中剩余的煎饼都不足以服务第六位顾客。

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.