A. Counterexample

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

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

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include <cmath>
  5. #include<algorithm>
  6. using namespace std;
  7.  
  8. typedef long long LL;
  9.  
  10. LL gcd(LL n,LL m){
  11. return m==? n:gcd(m,n%m);
  12. }
  13.  
  14. int main()
  15. {
  16. LL a,b,c,l,r;
  17. cin>>l>>r;
  18. for(a=l;a<=r;a++){
  19. for(b=a+;b<=r;b++){
  20. for(c=b+;c<=r;c++){
  21. if(gcd(a,b)==&&gcd(b,c)==&&gcd(a,c)!=){
  22. cout<<a<<' '<<b<<' '<<c<<"\n";
  23. return ;
  24. }
  25. }
  26. }
  27. }
  28. printf("-1\n");
  29. }

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写的,实在不懂,去翻了第二个提交的代码,发现这样做,更简单

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include <cmath>
  5. #include<algorithm>
  6. using namespace std;
  7.  
  8. typedef long long LL;
  9.  
  10. int main()
  11. {
  12. int n,x,i=,l,r;
  13. cin>>n>>x;
  14. for(i=;i<=n-x;i++) printf("%d ",i);
  15. r=n;
  16. l=n-x+;
  17. // printf("l=%d\n",l);
  18. for(i=;i<=x;i++)
  19. {
  20. if(i%) printf("%d ",r),r--;
  21. else printf("%d ",l),l++;
  22. }
  23. return ;
  24. }

这次做= =做了半小时就不想再做下去了= =连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. Win8必知快捷键汇总

    * Win+C:调出应用Charm菜单(开始界面.传统桌面) * Win+D:所有程序最小化,再次按下恢复(开始界面.传统桌面) * Win+E:打开我的电脑(开始界面.传统桌面) * Win+F:调 ...

  2. 为什么主流网站无法捕获 XSS 漏洞?

    二十多年来,跨站脚本(简称 XSS)漏洞一直是主流网站的心头之痛.为什么过了这么久,这些网站还是对此类漏洞束手无策呢? 对于最近 eBay 网站曝出的跨站脚本漏洞,你有什么想法?为什么会出现这样的漏网 ...

  3. codeforces 439C Devu and Partitioning of the Array(烦死人的多情况的模拟)

    题目 //这是一道有n多情况的烦死人的让我错了n遍的模拟题 #include<iostream> #include<algorithm> #include<stdio.h ...

  4. POJ 2674

    Linear world Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 2448   Accepted: 564 Descr ...

  5. Javascript 正则表达式_5

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  6. 被 Windows 10 SDK 坑了

    抓包抓到的配置文件与完整版的VS一致,虽然显示出来的只有 Windows 10 通用工具,我还以为是只更新这些(因为列出来的几个,我确实之前没装),就愉快地点了安装,结果……新建项目时,发现 Wind ...

  7. sqlserver 分页

    SQL语句: create PROCEDURE [dbo].[GetPageDataOutRowNumber] ( @tn nvarchar(),--表名称 @idn nvarchar(),--表主键 ...

  8. linux下ping加时间戳实时输出到文件 放后台运行

    放后台运行命令:setsid 实时输出命令:unbuffer 加时间戳:awk '{ print $0"\t" strftime("%D_%H:%M:%S",s ...

  9. VCC、VDD、VEE、VSS等有关电源标注的区别

    Almost all integrated circuits (ICs) have at least two pins which connect to the power rails of the ...

  10. Android笔记——RecyclerView替代ListView

    ListView是常用列表控件,但设置Adapter时自定义代码较为复杂,因此Android3.0后,增加RecyclerView替代ListView RecyclerView没有提供OnItemCl ...