蛋糕是个谎言AI (CI翻译)
To end the party, Alice decides to cook some pancakes for her friends.
为了结束聚会,Alice 决定为朋友们做一些煎饼。AI (CI翻译)
Alice has $n$ uncooked pancakes but only $2$ pans. Initially, the first $min(n,2)$ pancakes are on the pans, and all pancakes have cookedness $0$.
Alice 有 $n$ 个未烹饪的煎饼,但只有 $2$ 个煎锅。开始时,前 $min(n,2)$ 个煎饼分别放在煎锅上,所有煎饼的熟度均为 $0$。AI (CI翻译)
To cook her pancakes, Alice may perform the following two operations any number of times:
为了烹饪煎饼,Alice 可以执行以下两种操作任意次:AI (CI翻译)
- Cook the two pancakes on the pans for
$1$minute. The pancake on the first pan's cookedness increases by$a$, and the pancake on the second pan's cookedness increases by$b$. - Serve the first pancake, move the second pancake to the first pan, and add a new uncooked pancake to the second pan (if there are any completely uncooked pancakes left). Note that this takes no time, and can be done multiple times in a row.
- 将煎锅上的两个煎饼烹饪
$1$分钟。第一个煎锅上的煎饼熟度增加$a$,第二个煎锅上的煎饼熟度增加$b$。 - 端走第一个煎饼,将第二个煎饼移到第一个煎锅,并将一个新的未烹饪煎饼放入第二个煎锅(如果还有完全未烹饪的煎饼剩余)。注意,此操作不需要时间,并且可以连续执行多次。
Note that if there is only one pancake left, it will be on the first pan, gaining $a$ cookedness per minute until Alice decides to serve it.
注意,如果只剩下一个煎饼,它会位于第一个煎锅上,每分钟增加 $a$ 的熟度,直到 Alice 决定端走它。AI (CI翻译)
A pancake is perfectly cooked if and only if its cookedness is exactly $k$.
当且仅当一个煎饼的熟度恰好为 $k$ 时,该煎饼才算完美烹饪。AI (CI翻译)
Help Alice find the maximum number of perfectly cooked pancakes that she can serve.
请帮助 Alice 求出她最多可以端上多少个完美烹饪的煎饼。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.
每个测试包含多个测试用例。第一行包含测试用例的数量 $t$($1 \le t \le 1000$)。接下来描述各个测试用例。AI (CI翻译)
The only line in the test case contains $4$ integers $n$, $a$, $b$, and $k$ ($1 \le n,a,b,k \le 10^9$) — the number of pancake batter Alice has, the amount of cookedness the pancake on the first pan gains at the end of each minute, the amount of cookedness the pancake on the second pan gains at the end of each minute, and the amount of cookedness the pancake needs to have in order for it to be perfectly cooked.
每个测试用例仅一行,包含 $4$ 个整数 $n$、$a$、$b$ 和 $k$($1 \le n,a,b,k \le 10^9$),分别表示 Alice 拥有的煎饼面糊数量、第一个煎锅上的煎饼每分钟增加的熟度、第二个煎锅上的煎饼每分钟增加的熟度,以及煎饼达到完美烹饪所需的熟度。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, output the maximum number of perfectly cooked pancakes Alice can make.
对于每个测试用例,输出 Alice 最多可以制作的完美烹饪煎饼数量。AI (CI翻译)
Note
说明
AI (CI翻译)In the first testcase, Alice can perfectly cook all pancakes in a batch of two. Therefore, the maximum number of perfectly cooked pancakes is $17$.
在第一个测试用例中,Alice 可以每次同时完美烹饪两个煎饼。因此,最多可以得到 $17$ 个完美烹饪的煎饼。AI (CI翻译)
In the second test case, Alice will always overcook all pancakes since both pans are too hot. Therefore, the maximum number of perfectly cooked pancakes is $0$.
在第二个测试用例中,由于两个煎锅的温度都过高,所有煎饼都会被烤过头。因此,最多可以得到 $0$ 个完美烹饪的煎饼。AI (CI翻译)
In the third test case, Alice can leave the first two pancakes on the pans for $3003$ minutes, then serve both of them, one undercooked and one perfectly cooked. For the last pancake, she leaves it on the pan for $10\,101$ minutes before serving it to make it perfectly cooked. Since there are no ways to perfectly cook the first two pancakes (by the time the first pancake is perfectly cooked, the second pancake will be overcooked), the maximum number of perfectly cooked pancakes is $2$.
在第三个测试用例中,Alice 可以让最初的两个煎饼在煎锅上放置 $3003$ 分钟,然后将它们都端走,其中一个未熟,另一个恰好完美烹饪。对于最后一个煎饼,她让它在煎锅上放置 $10\,101$ 分钟后再端走,使其达到完美烹饪状态。由于不存在完美烹饪最初两个煎饼的方法(当第一个煎饼达到完美烹饪状态时,第二个煎饼已经烤过头了),因此最多可以得到 $2$ 个完美烹饪的煎饼。AI (CI翻译)
样例
7
17 1 1 1
123456789 987 654 321
3 11 37 111111
987654321 1 2 123456789
100 1 2 1
100 1 2 2
1 1 1 1
17
0
2
987654320
50
67
1
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。