CF1612C.Chat Ban
普及-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are a usual chat user on the most famous streaming platform. Of course, there are some moments when you just want to chill and spam something.
More precisely, you want to spam the emote triangle of size k. It consists of 2k−1 messages. The first message consists of one emote, the second one — of two emotes, ..., the k-th one — of k emotes, the k+1-th one — of k−1 emotes, ..., and the last one — of one emote.
For example, the emote triangle for k=3 consists of 5 messages:

Of course, most of the channels have auto moderation. Auto moderator of the current chat will ban you right after you spam at least x emotes in succession (you can assume you are the only user in the chat). Now you are interested — how many messages will you write before getting banned? Or maybe you will not get banned at all (i.e. will write all 2k−1 messages and complete your emote triangle successfully)? Note that if you get banned as a result of writing a message, this message is also counted.
You have to answer t independent test cases.
你是一位最著名流媒体平台上的普通聊天用户。当然,有时你只想放松一下,发一些刷屏消息。
更准确地说,你想刷屏一个大小为 k 的表情符号三角形。它由 2k−1 条消息组成:第一条消息包含 1 个表情符号,第二条包含 2 个表情符号,……,第 k 条包含 k 个表情符号,第 k+1 条包含 k−1 个表情符号,……,最后一条包含 1 个表情符号。
例如,当 k=3 时,该表情符号三角形由 5 条消息组成:

当然,大多数频道都启用了自动审核机制。当前聊天室的自动审核员会在你连续发送至少 x 个表情符号后立即封禁你(你可以假设你是聊天室中唯一的用户)。现在你想知道:在被封禁前,你能成功发送多少条消息?或者你根本不会被封禁(即成功发送全部 2k−1 条消息,完整地刷出这个表情符号三角形)?注意:如果你因发送某条消息而被封禁,则该消息也计入总消息数。
你需要回答 t 个相互独立的测试用例。
输入格式
The first line of the input contains one integer t (1≤t≤104) — the number of test cases. The next t lines describe test cases.
The only line of the test case contains integers k and x (1≤k≤109;1≤x≤1018).
输入的第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。接下来的 t 行描述各个测试用例。
每个测试用例仅有一行,包含两个整数 k 和 x(1≤k≤109;1≤x≤1018)。
输出格式
For each test case, print the number of messages you will write before getting banned for the corresponding values k and x.
对于每个测试用例,输出在对应参数 k 和 x 下被封禁前你将发送的消息数量。
输入输出样例
输入#1
7 4 6 4 7 1 2 3 7 2 5 100 1 1000000000 923456789987654321
输出#1
3 4 1 4 3 1 1608737403
说明/提示
Let's analyze the test cases of the example.
- In the first test case, you write three messages containing 1, 2 and 3 emotes respectively, and since 1+2+3≥6, you get banned after that.
- In the second test case, you write four messages containing 1, 2, 3 and 4 emotes respectively, and since 1+2+3+4≥7, you get banned after that.
- In the third test case, you write one message containing exactly 1 emote. It doesn't get you banned, since 1<2, but you have already finished posting your emote triangle. So you wrote one message successfully.
- In the fourth test case, you write four messages containing 1, 2, 3 and 2 emotes respectively, and since 1+2+3+2≥7, you get banned after that.
- In the fifth test case, you write three messages containing 1, 2 and 1 emote respectively. It doesn't get you banned, since 1+2+1<5, but you have already finished posting your emote triangle. So you wrote three messages successfully.
- In the sixth test case, since x=1, you get banned as soon as you send your first message.
- The seventh test case is too large to analyze, so we'll skip it.
我们来分析示例中的测试用例。
- 在第一个测试用例中,你发送了三条消息,分别包含 1、2 和 3 个表情符号;由于 1+2+3≥6,你在发送完这三条消息后被封禁。
- 在第二个测试用例中,你发送了四条消息,分别包含 1、2、3 和 4 个表情符号;由于 1+2+3+4≥7,你在发送完这四条消息后被封禁。
- 在第三个测试用例中,你发送了一条消息,恰好包含 1 个表情符号。这不会导致你被封禁,因为 1<2;但此时你已经完成了表情符号三角形的发布。因此你成功发送了一条消息。
- 在第四个测试用例中,你发送了四条消息,分别包含 1、2、3 和 2 个表情符号;由于 1+2+3+2≥7,你在发送完这四条消息后被封禁。
- 在第五个测试用例中,你发送了三条消息,分别包含 1、2 和 1 个表情符号。这不会导致你被封禁,因为 1+2+1<5;但此时你已经完成了表情符号三角形的发布。因此你成功发送了三条消息。
- 在第六个测试用例中,由于 x=1,你一发送第一条消息就会被封禁。
- 第七个测试用例规模过大,难以手动分析,因此我们跳过它。
输入解题思路,AI测评打分。不知道怎么写?