题意:给你n和k,然后让你找出n个数使得gcd(a1,a2)+gcd(a3,a4)+......的和等于k;

思路:如果n为奇数,让前n-3个数的相邻两个数都为1,n-2和n-1两个数gcd为k-ans;ans为前n-3个数的和。为偶数的话,让前n-2个数的相邻两个数都为1,n和n-1两个数gcd为k-ans;

 #include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#define maxn 10000
#define ll long long
using namespace std; int n,k;
vector<int>q; int main()
{
scanf("%d%d",&n,&k);
if((n%==&&(n/)>k)||(n%!=&&(n-)/>k))
{
printf("-1\n");
}
else
{
if(n==&&k==)
{
printf("1\n");
return ;
}
else if(n==&&k>)
{
printf("-1\n");
return ;
}
if(n%==)
{
int ans=;
ll c=;
for(int i=; i<=n-; i+=)
{
printf("%lld %lld ",c,c-);
c-=;
ans++;
}
printf("%lld %lld\n",(ll)(k-ans),(ll)((k-ans)*));
}
else
{
int ans1=;
ll c1=;
for(int i=; i<n-; i+=)
{
printf("%lld %lld ",c1,c1-);
c1-=;
ans1++;
}
printf("%lld %lld",(ll)(k-ans1),(ll)(k-ans1)*);
printf(" %lld\n",c1);
}
}
return ;
}

codeforces C. Mashmokh and Numbers的更多相关文章

  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. Codeforces Round #240 (Div. 2) C Mashmokh and Numbers

    , a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...

  3. [codeforces 55]D. Beautiful numbers

    [codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...

  4. codeforces 414D Mashmokh and Water Tanks

    codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如 ...

  5. Mashmokh and Numbers CodeForces - 415C

    题意:就是n个数和k,每次按顺序那两个数,最大公约数的和为k. 思路:注意:当n=1,k>0时一定不存在,还有n=1,k=0时为1即可. 然后再正常情况下,第一组的最大公约数为k-n/2+1即可 ...

  6. CodeForces - 1245A Good ol' Numbers Coloring (思维)

    Codeforces Round #597 (Div. 2 Consider the set of all nonnegative integers: 0,1,2,-. Given two integ ...

  7. CodeForces 682A Alyona and Numbers (水题)

    Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After fi ...

  8. Codeforces 449D Jzzhu and Numbers

    http://codeforces.com/problemset/problem/449/D 题意:给n个数,求and起来最后为0的集合方案数有多少 思路:考虑容斥,ans=(-1)^k*num(k) ...

  9. Codeforces 414B Mashmokh and ACM

    http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...

随机推荐

  1. SpringMVC DispatcherServlet 说明与web配置

    使用Spring MVC,配置DispatcherServlet是第一步. DispatcherServlet是一个Servlet,所以能够配置多个DispatcherServlet. Dispatc ...

  2. 【Spring五】AOP之使用注解配置

    AOP使用注解配置流程: 1.当spring容器启动时候.    < context:component- scan base-package= "cn.itheima03.sprin ...

  3. 实践过配置成功的VNC安装配置

    VNC安装步骤说明那个 1.安装图形界面    #yum install tigervnc-server tigervnc  2.启动VNCServer #vncserver 对应的关闭图形界面的命令 ...

  4. hihocoder 北大网络赛 E.

    给一个1000个点的多边形(从某个点依次按照外形给出每个节点),这个多边形不一定是凸多边形 再给一个圆,问这个多边形与圆相交区域的周长 我们将这个问题分成两个部分,第一部分是求线段在圆内的长度,第二部 ...

  5. PE File.

    Figure 1 - PE File The CLR header stores information to indicate that the PE file is a .NET executab ...

  6. (转)asp.net分页存储过程

    Asp.Net分页存储过程 SQL分页语句 一.比较万能的分页: sql代码: 1 2 3 select top 每页显示的记录数 * from topic where id not in  (sel ...

  7. SQLite 入门教程(三)好多约束 Constraints

    一.约束 Constraints 在上一篇随笔的结尾,我提到了约束, 但是在那里我把它翻译成了限定符,不太准确,这里先更正一下,应该翻译成约束更贴切一点. 那么什么是约束呢? 我们在数据库中存储数据的 ...

  8. Kettle 实现mysql数据库不同表之间数据同步——实验过程

    下面是试验的主要步骤: 在上一篇文章中LZ已经介绍了,实验的环境和实验目的. 在本篇文章中主要介绍侧重于对Kettle ETL的相应使用方法, 在这里LZ需要说明一下,LZ成为了避免涉及索引和表连接等 ...

  9. oracle数据库读取操作系统的物理文件-转载,待完善

    --源地址不详 --创建目录SQL> create directory dir_xls as '/home/oracle'; Directory created. --给用户授权SQL> ...

  10. javascript DOM小结

    一:定义 dom:文档对象模型. dom是针对HTML和XML文档的一个API.dom描绘了一个层次化的节点树,允许开发人员添加.移除.修改页面的某一部分. 1:childNodes(返回当前节点的子 ...