A14713 | Chat Ban
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line of the input contains one integer $t$ ( $1 \le t \le 10^4$ ) — 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 \le k \le 10^9; 1 \le x \le 10^{18}$ ).
The only line of the test case contains integers $k$ and $x$ ( $1 \le k \le 10^9; 1 \le x \le 10^{18}$ ).
输出格式
For each test case, print the number of messages you will write before getting banned for the corresponding values $k$ and $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.
1. In the first test case, you write three messages containing $1$ , $2$ and $3$ emotes respectively, and since $1 + 2 + 3 \ge 6$ , you get banned after that.
2. In the second test case, you write four messages containing $1$ , $2$ , $3$ and $4$ emotes respectively, and since $1 + 2 + 3 + 4 \ge 7$ , you get banned after that.
3. 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.
4. In the fourth test case, you write four messages containing $1$ , $2$ , $3$ and $2$ emotes respectively, and since $1 + 2 + 3 + 2 \ge 7$ , you get banned after that.
5. 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.
6. In the sixth test case, since $x = 1$ , you get banned as soon as you send your first message.
7. The seventh test case is too large to analyze, so we'll skip it.
1. In the first test case, you write three messages containing $1$ , $2$ and $3$ emotes respectively, and since $1 + 2 + 3 \ge 6$ , you get banned after that.
2. In the second test case, you write four messages containing $1$ , $2$ , $3$ and $4$ emotes respectively, and since $1 + 2 + 3 + 4 \ge 7$ , you get banned after that.
3. 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.
4. In the fourth test case, you write four messages containing $1$ , $2$ , $3$ and $2$ emotes respectively, and since $1 + 2 + 3 + 2 \ge 7$ , you get banned after that.
5. 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.
6. In the sixth test case, since $x = 1$ , you get banned as soon as you send your first message.
7. The seventh test case is too large to analyze, so we'll skip it.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted