题目链接

首先考虑无解的情况: n / 2 > k 或者 n==1 且 k != 0 (因为两个数的最大公约数最小为1)

然后因为有 n / 2 组(把 a[i] 和 a[i+1] 看成一组), 所以我可以试 a[1] 和 a[2]的最大公约数为 k - n / 2 + 1, 这样后面的每个组只需要为1,就可以满足条件,

所以前面两个数可以为: k - n / 2 + 1 和 2 * (k - n / 2 + 1), 这样他们的最大公约数就是 k - n / 2 + 1

附上代码:

 n, k = map(int, raw_input().split())
if n / 2 > k or (n == 1 and k != 0):
print -1
elif n / 2 == k:
for i in xrange(n):
print i + 1,
else:
tmp = k - n / 2 + 1
print tmp, tmp << 1,
tmp *= 2;
for i in xrange(n-2):
print tmp + i + 1,

Codeforces 414A的更多相关文章

  1. codeforces 414A A. Mashmokh and Numbers(素数筛)

    题目链接: A. Mashmokh and Numbers time limit per test 1 second memory limit per test 256 megabytes input ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. __name__ = '__main__'

    有句话经典的概括了这段代码的意义: “Make a script both importable and executable” 意思就是说让你写的脚本模块既可以导入到别的模块中用,另外该模块自己也可 ...

  2. Vue 本地代理 纯前端技术解决跨域

    vue-axios获取数据很多小伙伴都会使用,但如果前后端分离且后台没设置跨域许可,那要怎样才能解决跨域问题? 常用方法有几种: 通过jsonp跨域 通过修改document.domain来跨子域 使 ...

  3. python学习之路-day1

    1 变量 赋值:变量可以是字符串.序列.元组. # author:hams.ali # 界面 line = '-*'*20 # 数字直接可以计算 _var1 = ' # 字符变量拼接 _var_2 = ...

  4. python intern(字符串驻留机制)

    python 中为了提高字符串的使用用效率和节约内存,对于由 字母.数字.下划线组成的标识符采用了 intern 机制,即对于短字符串,将其赋值给多个对象时,内存中只有一个副本,多个对象共享这个副本. ...

  5. 注册.NET Framework

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe /i

  6. 如何将本地项目上传到Git 版本库

    1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库 git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点 ...

  7. git学习记录——基础概念和文件的基本操作

    夸一下git git是当前世界上最先进的分布式版本控制系统 优势: 1.不必联网 2.Git极其强大的分支管理,把SVN等远远抛在了后面. 集中式的代表CVS和SVN 分布式的代表BitKeeper, ...

  8. poj1160 动态规划

    #include<stdio.h> #include<string.h> #define INF 999999999 #define Min(x,y) (x<y?x:y) ...

  9. LintCode 合并两个排序

    将两个排序链表合并为一个新的排序链表 样例 给出 1->3->8->11->15->null,2->null, 返回1->2->3->8-> ...

  10. Java review-basic2

    1.Implement a thread-safe (blocking) queue: Class Producer implements Runable{ Private final Blockin ...