A15988 | Rudolf and Snowflakes (simple version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
This is a simple version of the problem. The only difference is that in this version $n \le 10^6$ .
One winter morning, Rudolf was looking thoughtfully out the window, watching the falling snowflakes. He quickly noticed a certain symmetry in the configuration of the snowflakes. And like a true mathematician, Rudolf came up with a mathematical model of a snowflake.
He defined a snowflake as an undirected graph constructed according to the following rules:
- Initially, the graph has only one vertex.
- Then, more vertices are added to the graph. The initial vertex is connected by edges to $k$ new vertices ( $k > 1$ ).
- Each vertex that is connected to only one other vertex is connected by edges to $k$ more new vertices. This step should be done at least once.
The smallest possible snowflake for $k = 4$ is shown in the figure.
After some mathematical research, Rudolf realized that such snowflakes may not have any number of vertices. Help Rudolf check if a snowflake with $n$ vertices can exist.
One winter morning, Rudolf was looking thoughtfully out the window, watching the falling snowflakes. He quickly noticed a certain symmetry in the configuration of the snowflakes. And like a true mathematician, Rudolf came up with a mathematical model of a snowflake.
He defined a snowflake as an undirected graph constructed according to the following rules:
- Initially, the graph has only one vertex.
- Then, more vertices are added to the graph. The initial vertex is connected by edges to $k$ new vertices ( $k > 1$ ).
- Each vertex that is connected to only one other vertex is connected by edges to $k$ more new vertices. This step should be done at least once.
The smallest possible snowflake for $k = 4$ is shown in the figure.
After some mathematical research, Rudolf realized that such snowflakes may not have any number of vertices. Help Rudolf check if a snowflake with $n$ vertices can exist.
输入格式
The first line of the input contains an integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases.
Then follow the descriptions of the test cases.
The first line of each test case contains an integer $n$ ( $1 \le n \le 10^6$ ) — the number of vertices for which it is necessary to check the existence of a snowflake.
Then follow the descriptions of the test cases.
The first line of each test case contains an integer $n$ ( $1 \le n \le 10^6$ ) — the number of vertices for which it is necessary to check the existence of a snowflake.
输出格式
Output $t$ lines, each of which is the answer to the corresponding test case — "YES" if there exists such $k > 1$ for which a snowflake with the given number of vertices can be constructed; "NO" otherwise.
输入输出样例
输入 #1
9 1 2 3 6 13 15 255 10101 1000000
输出 #1
NO NO NO NO YES YES YES YES NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted