A. Counterexample

题意:给出l,r,找出使得满足l<a<b<c<r,同时满足a,b的最大公约数为1,b,c的最大公约数为1,且a,b的最大公约数不为1

因为题目里说了l-r<=50,所以可以直接枚举

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; LL gcd(LL n,LL m){
return m==? n:gcd(m,n%m);
} int main()
{
LL a,b,c,l,r;
cin>>l>>r;
for(a=l;a<=r;a++){
for(b=a+;b<=r;b++){
for(c=b+;c<=r;c++){
if(gcd(a,b)==&&gcd(b,c)==&&gcd(a,c)!=){
cout<<a<<' '<<b<<' '<<c<<"\n";
return ;
}
}
}
}
printf("-1\n");
}

C. Diverse Permutation

题意:给出n,原始的排列即为1 2 3 4 5 -----n,再给出k,使得新的排列中满足 |p1-p2|,|p2-p3|,..,|pn-1-pn|只有x个不相同

因为只有x个不相同,所以有n-x个是相同的,先按照自然数的序列放前n-x个数 然后剩下的x个数则交替放置,

自己先搜题解的时候,发现一个用hash写的,实在不懂,去翻了第二个提交的代码,发现这样做,更简单

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; int main()
{
int n,x,i=,l,r;
cin>>n>>x;
for(i=;i<=n-x;i++) printf("%d ",i);
r=n;
l=n-x+;
// printf("l=%d\n",l);
for(i=;i<=x;i++)
{
if(i%) printf("%d ",r),r--;
else printf("%d ",l),l++;
}
return ;
}

这次做= =做了半小时就不想再做下去了= =连A的题意都不是很懂(数论做得太少太少拉)B现在还不太明白,C想到了也好理解= =可是当时想的是老老实实枚举,得枚到啥时候----哎----

加油啊--go---go--go

B再补吧= =

Codeforces Round #275 (Div. 2)的更多相关文章

  1. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  2. Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造

    Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 ht ...

  3. 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation

    题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...

  4. [Codeforces Round #275 (Div. 2)]B - Friends and Presents

    最近一直在做 codeforces ,总觉得已经刷不动 BZOJ 了? ——真是弱喵 你看连 Div.2 的 B 题都要谢谢题解,不是闲就是傻 显然我没那么闲 ╮(╯_╰)╭ 我觉得这题的想法挺妙的~ ...

  5. Codeforces Round #275 (Div. 2) C

    题目传送门:http://codeforces.com/contest/483/problem/C 题意分析:题目意思没啥好说的. 去搞排列列举必须TLE.那么就想到构造. 1.n.2.n-1.3.n ...

  6. Codeforces Round #275(Div. 2)-C. Diverse Permutation

    http://codeforces.com/contest/483/problem/C C. Diverse Permutation time limit per test 1 second memo ...

  7. Codeforces Round #275 (Div. 2)-A. Counterexample

    http://codeforces.com/contest/483/problem/A A. Counterexample time limit per test 1 second memory li ...

  8. Codeforces Round #275 Div.1 B Interesting Array --线段树

    题意: 构造一个序列,满足m个形如:[l,r,c] 的条件. [l,r,c]表示[l,r]中的元素按位与(&)的和为c. 解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的 ...

  9. Codeforces Round #275 (Div. 2) 题解

    A 题: 说的是在(LR) 之间找出ab互质 bc 互质 ac 不互质的 3个数 数据量小直接暴力 #include <iostream> #include <cstdio> ...

随机推荐

  1. centos mysql 操作

    安装mysqlyum -y install mysql-server 修改mysql配置 vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记 暂时修改一下编码(添加在密码下 ...

  2. AssetBundle机制相关资料收集

    原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...

  3. sream bytes[] img相互转换

    /// <summary> /// 将 Stream 转成 byte[] /// </summary> /// <param name="stream" ...

  4. Unit4中的Annotation

    Unit4中的Annotation(注解.注释) JUnit4 使用 Java 5 中的注解(annotation),以下是JUnit4 常用的几个annotation介绍@Before:初始化方法@ ...

  5. Spring MVC 教程,快速入门,深入分析(转)

    原文地址:http://elf8848.iteye.com/blog/875830/

  6. iOS开发--git

    http://blog.chinaunix.net/uid-26495963-id-3474178.html 相关知识 gnu interactive tools 一句话概括git: Git is a ...

  7. Java-J2SE学习笔记-查找一个String中,subString的出现次数

    1.查找一个String中,subString的出现次数 2.代码 package Test; public class TestStringContain { public static void ...

  8. mysql 常用命令(备忘)

    1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:2.创建一个数据库MYSQLDATA mysql> CREATE DATABASE ...

  9. 模拟登陆115网盘(MFC版)

    [cpp] view plain copy // 模拟登陆115网盘 #include <afxinet.h> // 包含相关的头文件 /* 用抓包工具抓包可得到需要提交的数据,然后模拟提 ...

  10. apache-hadoop-1.2.1、hbase、hive、mahout、nutch、solr安装教程

    1 软件环境: VMware8.0 Ubuntu-12.10-desktop-i386 jdk-7u40-linux-i586.tar.gz hadoop-1.2.1.tar.gz eclipse-d ...