果然abc都是手速场。

倒序开的qwq。

D题因为忘记1e12二进制几位上界爆了一发。

A - Entrance Examination

就是除一下就行了。。。

看样例猜题意系列。

  1. #include<cstdio>
  2. #include<algorithm>
  3. #include<cstring>
  4. int main(){
  5. double t,x;
  6. scanf("%lf%lf",&t,&x);
  7. printf("%lf",t/x);
  8. return 0;
  9. }

B - Polygon

他都把定理给你了。。。

你直接按他的意思模拟就好,数组都不用开

  1. #include <bits/stdc++.h>
  2. int main() {
  3. int n, sum = 0, mx = 0;
  4. scanf("%d", &n);
  5. for(int x, i = 1; i <= n; ++i) {
  6. scanf("%d", &x);
  7. sum += x;
  8. mx = std::max(mx, x);
  9. }
  10. if(mx < sum - mx) puts("Yes");
  11. else puts("No");
  12. }

C - Streamline

直接贪心就好了。

我们把序列先排序然后差分一下。

显然中间那些长的间隔我们不要走。

所以把间隔排序。

然后再间隔的右边放一个棋子就好了。

也就是说前m大的间隔我们都不用走。这个想了挺久的。。。

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <vector>
  7. #include <queue>
  8. #include <cmath>
  9. #include <stack>
  10. #include <deque>
  11. #include <map>
  12. #include <set>
  13. #define ll long long
  14. #define inf 0x3f3f3f3f
  15. #define il inline
  16. namespace io {
  17. #define in(a) a=read()
  18. #define out(a) write(a)
  19. #define outn(a) out(a),putchar('\n')
  20. #define I_int ll
  21. inline I_int read() {
  22. I_int x = 0 , f = 1 ; char c = getchar() ;
  23. while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
  24. while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
  25. return x * f ;
  26. }
  27. char F[ 200 ] ;
  28. inline void write( I_int x ) {
  29. if( x == 0 ) { putchar( '0' ) ; return ; }
  30. I_int tmp = x > 0 ? x : -x ;
  31. if( x < 0 ) putchar( '-' ) ;
  32. int cnt = 0 ;
  33. while( tmp > 0 ) {
  34. F[ cnt ++ ] = tmp % 10 + '0' ;
  35. tmp /= 10 ;
  36. }
  37. while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
  38. }
  39. #undef I_int
  40. }
  41. using namespace io ;
  42. using namespace std ;
  43. #define N 100010
  44. int m = read(), n = read();
  45. int a[N], f[N];
  46. bool cmp(int a, int b) {
  47. return a > b;
  48. }
  49. int main() {
  50. for(int i = 1; i <= n; ++i) a[i] = read();
  51. sort(a + 1, a + n + 1);
  52. if(m >= n) return puts("0"), 0;
  53. int cnt = 0;
  54. for(int i = 2; i <= n; ++i) {
  55. f[++cnt] = a[i] - a[i - 1];
  56. }
  57. sort(f + 1, f + n + 1, cmp);
  58. ll ans = 0;
  59. for(int i = m; i <= n; ++i) ans += f[i];
  60. printf("%lld\n", ans);
  61. }

D - XXOR

据说样例锅了?

反正我记错位运算+上界算错这题卡了半小时。。。

因为是XOR所以我们按位来考虑,从高位往低位贪心。

XOR是不进位的加法,我们从这个角度来考虑。

统计该位上0个数和1个数。

如果0的个数多显然题面里的那个x这一位就必须有1(在x不超过k的情况下)。

注意开1ll,以及不要记错取出一个数的第k位的位运算是长啥样的。。。

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <vector>
  7. #include <queue>
  8. #include <cmath>
  9. #include <stack>
  10. #include <deque>
  11. #include <map>
  12. #include <set>
  13. #define ll long long
  14. #define inf 0x3f3f3f3f
  15. #define il inline
  16. namespace io {
  17. #define in(a) a=read()
  18. #define out(a) write(a)
  19. #define outn(a) out(a),putchar('\n')
  20. #define I_int ll
  21. inline I_int read() {
  22. I_int x = 0 , f = 1 ; char c = getchar() ;
  23. while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
  24. while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
  25. return x * f ;
  26. }
  27. char F[ 200 ] ;
  28. inline void write( I_int x ) {
  29. if( x == 0 ) { putchar( '0' ) ; return ; }
  30. I_int tmp = x > 0 ? x : -x ;
  31. if( x < 0 ) putchar( '-' ) ;
  32. int cnt = 0 ;
  33. while( tmp > 0 ) {
  34. F[ cnt ++ ] = tmp % 10 + '0' ;
  35. tmp /= 10 ;
  36. }
  37. while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
  38. }
  39. #undef I_int
  40. }
  41. using namespace io ;
  42. using namespace std ;
  43. #define N 100010
  44. ll n = read(), K = read();
  45. ll a[N], cnt[2];
  46. bool cmp(int a, int b) {
  47. return a > b;
  48. }
  49. int main() {
  50. for(int i = 1; i <= n; ++i) a[i] = read();
  51. ll ans = 0;
  52. for(ll k = 42; k >= 0; --k) {
  53. cnt[0] = cnt[1] = 0;
  54. for(int i = 1; i <= n; ++i) {
  55. cnt[(a[i]>>k)&1ll]++;
  56. }
  57. if(cnt[0] > cnt[1] && ans + (1ll << k) <= K) ans += (1ll << k);
  58. }
  59. ll sum = 0;
  60. for(int i = 1; i <= n; ++i) {
  61. sum += ans ^ a[i];
  62. }
  63. printf("%lld\n", sum);
  64. return 0;
  65. }

AtCoder Beginner Contest 117 解题报告的更多相关文章

  1. AtCoder Beginner Contest 122 解题报告

    手速选手成功混进rated only里面的前30名,但是总排名就到110+了... A - Double Helix #include <bits/stdc++.h> #define ll ...

  2. AtCoder Beginner Contest 146解题报告

    题目地址 https://atcoder.jp/contests/abc146/tasks 感觉没有什么有意思的题... 题解 A #include <bits/stdc++.h> usi ...

  3. Atcoder Beginner Contest 124 解题报告

    心态爆炸.本来能全做出来的.但是由于双开了Comet oj一个比赛,写了ABC就去搞那个的B题 还被搞死了. 回来写了一会D就过了.可惜比赛已经结束了.真的是作死. A - Buttons #incl ...

  4. AtCoder Beginner Contest 118 解题报告

    A - B +/- A #include <bits/stdc++.h> int main() { int a, b; std::cin >> a >> b; b ...

  5. AtCoder Beginner Contest 120 解题报告

    为啥最近都没有arc啊... A - Favorite Sound #include <algorithm> #include <iostream> #include < ...

  6. AtCoder Beginner Contest 132 解题报告

    前四题都好水.后面两道题好难. C Divide the Problems #include <cstdio> #include <algorithm> using names ...

  7. AtCoder Beginner Contest 129 解题报告

    传送门 写了四个题就跑去打球了.第五题应该能肝出来的. A - Airplane #include <bits/stdc++.h> using namespace std; inline ...

  8. AtCoder Beginner Contest 127 解题报告

    传送门 非常遗憾.当天晚上错过这一场.不过感觉也会掉分的吧.后面两题偏结论题,打了的话应该想不出来. A - Ferris Wheel #include <bits/stdc++.h> u ...

  9. AtCoder Beginner Contest 126 解题报告

    突然6道题.有点慌.比赛写了五个.罚时爆炸.最后一个时间不太够+没敢写就放弃了. 两道题奇奇怪怪的WJ和20/20.今天的评测机是怎么了. A Changing a Character #includ ...

随机推荐

  1. CentOS下nginx+php的配置及nginx开机启动配置

    关闭防火墙 (不然外链接是访问不了 apache) service iptables stop 关闭安全系统 SELinux( 不然报403 访问页面错误 ) 1.Nginx安装主要在于配置文件的修改 ...

  2. Nginx技术研究系列6-配置详解

    前两篇文章介绍了Nginx反向代理和动态路由: Ngnix技术研究系列1-通过应用场景看Nginx的反向代理 Ngnix技术研究系列2-基于Redis实现动态路由 随着研究的深入,很重要的一点就是了解 ...

  3. 入坑tensorflow

    win10 CPU版,anaconda prompt命令行一句话,pip install --upgrade tensorflow搞定.比caffe好装一万倍. gpu版没装成,首先这个笔记本没装cu ...

  4. Struts2输入校验(XML方式)

    本章主要介绍struts2的XML配置方式输入校验.以下将结合一个实例程序进行说明. 代码结构: 关键代码: RegistAction.javapackage com.alfred.regist.ac ...

  5. linux常用命令:pwd 命令

    Linux中用 pwd 命令来查看”当前工作目录“的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录.在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置. ...

  6. pyspider操作千万级库,pyspider在对接量级较大库的策略

    pyspider操作千万级库,pyspider在对接量级较大库的策略 如果是需要pyspider正常的流程去执行,那必然是会在on_strat()时任务执行超时,可能只读取出几万条或十几万条数据就会被 ...

  7. <转>jmeter(十三)常见问题及解决方法

    本博客转载自:http://www.cnblogs.com/imyalost/category/846346.html 个人感觉不错,对jmeter讲解非常详细,担心以后找不到了,所以转发出来,留着慢 ...

  8. 每日linux命令学习-lsattr和chattr

    lsattr和chattr命令 1. lsattr命令 作用: 显示文件属性 语法: lsattr [-adlRvV][files...] 参数: -a 显示所有文件和目录(包括隐藏文件)的属性. - ...

  9. Oracle与MySQL区别

    MyBatis中模糊查询,mysql可以用concat,而oracle用"||"; 另外,mysql支持主键自增,而oracle不支持主键自增.

  10. mycat水平分表

    和垂直分库不同,水平分表,是将那些io频繁,且数据量大的表进行水平切分. 基本的配置和垂直分库一样,我们需要改的就是我们的 schema.xml和rule.xml文件配置(server.xml不用做任 ...