A15911 | Dreaming of Freedom
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Because to take away a man's freedom of choice, even his freedom to make the wrong choice, is to manipulate him as though he were a puppet and not a person.
— Madeleine L'Engle
There are $n$ programmers choosing their favorite algorithm amongst $m$ different choice options. Before the first round, all $m$ options are available. In each round, every programmer makes a vote for one of the remaining algorithms. After the round, only the algorithms with the maximum number of votes remain. The voting process ends when there is only one option left. Determine whether the voting process can continue indefinitely or no matter how people vote, they will eventually choose a single option after some finite amount of rounds?
— Madeleine L'Engle
There are $n$ programmers choosing their favorite algorithm amongst $m$ different choice options. Before the first round, all $m$ options are available. In each round, every programmer makes a vote for one of the remaining algorithms. After the round, only the algorithms with the maximum number of votes remain. The voting process ends when there is only one option left. Determine whether the voting process can continue indefinitely or no matter how people vote, they will eventually choose a single option after some finite amount of rounds?
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 10^5$ ) — the number of test cases.
Each test case consists of a single line containing two integers $n$ and $m$ ( $1 \leq n, m \leq 10^6$ ) — the number of people and choice options respectively.
Each test case consists of a single line containing two integers $n$ and $m$ ( $1 \leq n, m \leq 10^6$ ) — the number of people and choice options respectively.
输出格式
For each test case output "YES" if the programmers will eventually choose a single option, and "NO" otherwise.
You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as a positive answer).
You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as a positive answer).
输入输出样例
输入 #1
5 3 2 4 2 5 3 1000000 1000000 1 1000000
输出 #1
YES NO YES NO YES
In the first example, there are $8$ ways people could vote: $\{1|1|1, 1|1|2, 1|2|1, 1|2|2, 2|1|1, 2|1|2, 2|2|1, 2|2|2\}$ .
In cases $1$ , $2$ , $3$ , and $5$ , the programmers are left with the first algorithm, and in the remaining cases people are left with the second one, so the voting ends in one round in any case.
In the second example, the programmers could always vote $1|1|2|2$ . Both algorithms have the maximum number of votes and remain for the next round, so the voting never ends.
In cases $1$ , $2$ , $3$ , and $5$ , the programmers are left with the first algorithm, and in the remaining cases people are left with the second one, so the voting ends in one round in any case.
In the second example, the programmers could always vote $1|1|2|2$ . Both algorithms have the maximum number of votes and remain for the next round, so the voting never ends.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted