A7874 | Prime Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In Berland prime numbers are fashionable — the respectable citizens dwell only on the floors with numbers that are prime numbers. The numismatists value particularly high the coins with prime nominal values. All the prime days are announced holidays!
Yet even this is not enough to make the Berland people happy. On the main street of the capital stand $n$ houses, numbered from 1 to $n$ . The government decided to paint every house a color so that the sum of the numbers of the houses painted every color is a prime number.
However it turned out that not all the citizens approve of this decision — many of them protest because they don't want many colored houses on the capital's main street. That's why it is decided to use the minimal possible number of colors. The houses don't have to be painted consecutively, but every one of $n$ houses should be painted some color. The one-colored houses should not stand consecutively, any way of painting is acceptable.
There are no more than 5 hours left before the start of painting, help the government find the way when the sum of house numbers for every color is a prime number and the number of used colors is minimal.
Yet even this is not enough to make the Berland people happy. On the main street of the capital stand $n$ houses, numbered from 1 to $n$ . The government decided to paint every house a color so that the sum of the numbers of the houses painted every color is a prime number.
However it turned out that not all the citizens approve of this decision — many of them protest because they don't want many colored houses on the capital's main street. That's why it is decided to use the minimal possible number of colors. The houses don't have to be painted consecutively, but every one of $n$ houses should be painted some color. The one-colored houses should not stand consecutively, any way of painting is acceptable.
There are no more than 5 hours left before the start of painting, help the government find the way when the sum of house numbers for every color is a prime number and the number of used colors is minimal.
输入格式
The single input line contains an integer $n$ ( $2<=n<=6000$ ) — the number of houses on the main streets of the capital.
输出格式
Print the sequence of $n$ numbers, where the $i$ -th number stands for the number of color for house number $i$ . Number the colors consecutively starting from 1. Any painting order is allowed. If there are several solutions to that problem, print any of them. If there's no such way of painting print the single number -1.
输入输出样例
输入 #1
8
输出 #1
1 2 2 1 1 1 1 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted