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. ThinkPHP3.2 分页实现

    ThinkPHP 分页实现   TP3.2框架手册,有一个数据分页,不过每次都要写太多的代码,还有中文设置等有些麻烦,做为程序开发者,有必要整理下: O.先看效果图 一.分页方法 /** * TODO ...

  2. POJ 2010

    Moo University - Financial Aid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4235   A ...

  3. POJ 2126

    #include <iostream> using namespace std; int n; int main() { //freopen("acm.acm",&qu ...

  4. MySQL 5.1参考手册

    目录 前言 1. 一般信息 1.1. 关于本手册 1.2. 本手册采用的惯例 1.3. MySQL AB概述 1.4. MySQL数据库管理系统概述 1.4.1. MySQL的历史 1.4.2. My ...

  5. UVA 11038 - How Many O's? 计算对答案的贡献

    题意: 求[n, m]之间包含0的数字的个数题解:转化为求solve(n) - solve(m-1)的前缀问题 对于求0到n的解,我们举例 n = 25789 对于8这位,让其为0对答案的贡献是 (0 ...

  6. copy

    拷贝文件,不覆盖重复文件 yes no|cp -i a b

  7. Spark源码分析环境搭建

    原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/3868718.html 本文主要分享一下如何构建Spark源码分析环境.以前主要使用eclipse来阅读源 ...

  8. 【Apache运维基础(4)】Apache的Rewrite攻略(1)

    简述 Rewirte主要的功能就是实现URL的跳转,它的正则表达式是基于Perl语言.可基于服务器级的(httpd.conf)和目录级的 (.htaccess)两种方式.如果要想用到rewrite模块 ...

  9. list, set操作

    def union_list(l1, l2): result = [] if not l1: result.extend(l2) return result if not l2: result.ext ...

  10. mysql集群

    http://blog.chinaunix.net/uid-20586655-id-291471.html