A9406 | Mashmokh and Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of $n$ distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he removes the first and the second integer of the remaining sequence from the board, and so on. Bimokh stops when the board contains less than two numbers. When Bimokh removes numbers $x$ and $y$ from the board, he gets $gcd(x,y)$ points. At the beginning of the game Bimokh has zero points.
Mashmokh wants to win in the game. For this reason he wants his boss to get exactly $k$ points in total. But the guy doesn't know how choose the initial sequence in the right way.
Please, help him. Find $n$ distinct integers $a_{1},a_{2},...,a_{n}$ such that his boss will score exactly $k$ points. Also Mashmokh can't memorize too huge numbers. Therefore each of these integers must be at most $10^{9}$ .
In this game Mashmokh writes sequence of $n$ distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he removes the first and the second integer of the remaining sequence from the board, and so on. Bimokh stops when the board contains less than two numbers. When Bimokh removes numbers $x$ and $y$ from the board, he gets $gcd(x,y)$ points. At the beginning of the game Bimokh has zero points.
Mashmokh wants to win in the game. For this reason he wants his boss to get exactly $k$ points in total. But the guy doesn't know how choose the initial sequence in the right way.
Please, help him. Find $n$ distinct integers $a_{1},a_{2},...,a_{n}$ such that his boss will score exactly $k$ points. Also Mashmokh can't memorize too huge numbers. Therefore each of these integers must be at most $10^{9}$ .
输入格式
The first line of input contains two space-separated integers $n,k (1<=n<=10^{5}; 0<=k<=10^{8})$ .
输出格式
If such sequence doesn't exist output -1 otherwise output $n$ distinct space-separated integers $a_{1},a_{2},...,a_{n} (1<=a_{i}<=10^{9})$ .
输入输出样例
输入 #1
5 2
输出 #1
1 2 3 4 5
输入 #2
5 3
输出 #2
2 4 3 7 1
输入 #3
7 2
输出 #3
-1
$gcd(x,y)$ is greatest common divisor of $x$ and $y$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted