水 A. A and B and Chess

  1. /*
  2. 水题
  3. */
  4. #include <cstdio>
  5. #include <algorithm>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <string>
  9. using namespace std;
  10.  
  11. const int maxn = 1e6 + 10;
  12. int a[maxn];
  13.  
  14. int main(void)
  15. {
  16. //freopen ("A.in", "r", stdin);
  17.  
  18. string s1;
  19. int suma = 0; int sumb = 0;
  20. for (int i=1; i<=8; ++i)
  21. {
  22. cin >> s1;
  23. for (int j=0; s1[j]!='\0'; ++j)
  24. {
  25. if (s1[j] == '.') continue;
  26. else if (s1[j] == 'Q') suma += 9;
  27. else if (s1[j] == 'R') suma += 5;
  28. else if (s1[j] == 'B') suma += 3;
  29. else if (s1[j] == 'N') suma += 3;
  30. else if (s1[j] == 'P') suma += 1;
  31. else if (s1[j] == 'q') sumb += 9;
  32. else if (s1[j] == 'r') sumb += 5;
  33. else if (s1[j] == 'b') sumb += 3;
  34. else if (s1[j] == 'n') sumb += 3;
  35. else if (s1[j] == 'p') sumb += 1;
  36. }
  37. }
  38.  
  39. if (suma > sumb) cout << "White" << endl;
  40. else if (suma < sumb) cout << "Black" << endl;
  41. else cout << "Draw" << endl;
  42.  
  43. return 0;
  44. }

水 B. A and B and Compilation Errors

题意:三组数列,依次少一个,找出少了的两个数

思路:

1. 三次排序,逐个对比(如果没找到,那个数在上一个数列的末尾)
2. 求和做差,最简单!

  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. const int maxn = 1e5 + 10;
  7. int a[maxn];
  8. int b[maxn];
  9. int c[maxn];
  10.  
  11. int main(void)
  12. {
  13. //freopen ("B.in", "r", stdin);
  14.  
  15. int n, x, y;
  16.  
  17. while (~scanf ("%d", &n))
  18. {
  19. x = y = 0;
  20. for (int i=1; i<=n; ++i)
  21. {
  22. scanf ("%d", &a[i]);
  23. }
  24. sort (a+1, a+1+n);
  25. for (int i=1; i<=n-1; ++i)
  26. {
  27. scanf ("%d", &b[i]);
  28. }
  29. sort (b+1, b+1+n-1);
  30. for (int i=1; i<=n-1; ++i)
  31. {
  32. if (a[i] == b[i]) continue;
  33. else
  34. {
  35. x = a[i];
  36. break;
  37. }
  38. }
  39. if (x == 0) x = a[n];
  40. for (int i=1; i<=n-2; ++i)
  41. {
  42. scanf ("%d", &c[i]);
  43. }
  44. sort (c+1, c+1+n-2);
  45. for (int i=1; i<=n-2; ++i)
  46. {
  47. if (b[i] == c[i]) continue;
  48. else
  49. {
  50. y = b[i];
  51. break;
  52. }
  53. }
  54. if (y == 0) y = b[n-1];
  55. printf ("%d\n%d\n", x, y);
  56.  
  57. }
  58.  
  59. return 0;
  60. }
  61.  
  62. /*
  63. #include <cstdio>
  64. #include <algorithm>
  65. #include <iostream>
  66. using namespace std;
  67.  
  68. const int maxn = 1e5 + 10;
  69. int a[maxn];
  70. int b[maxn];
  71. int c[maxn];
  72. int suma, sumb, sumc;
  73.  
  74. int main(void)
  75. {
  76. //freopen ("B.in", "r", stdin);
  77.  
  78. int n;
  79.  
  80. while (~scanf ("%d", &n))
  81. {
  82. suma = sumb = sumc = 0;
  83. for (int i=1; i<=n; ++i)
  84. {
  85. scanf ("%d", &a[i]); suma += a[i];
  86. }
  87. for (int i=1; i<=n-1; ++i)
  88. {
  89. scanf ("%d", &b[i]); sumb += b[i];
  90. }
  91. for (int i=1; i<=n-2; ++i)
  92. {
  93. scanf ("%d", &c[i]); sumc += c[i];
  94. }
  95.  
  96. printf ("%d\n%d\n", suma - sumb, sumb - sumc);
  97. }
  98.  
  99. return 0;
  100. }
  101. */

构造 C. A and B and Team Training

题意:方案:高手1和菜鸟2 或者 高手2菜鸟1 三人组队求最大组队数
思路:

1. 高手加菜鸟每三个分开,在n,m的数字之内
2. 高手多,高手2;菜鸟多,菜鸟2 比较好理解

  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. //freopen ("C.in", "r", stdin);
  8.  
  9. int n, m;
  10.  
  11. while (~scanf ("%d%d", &n, &m))
  12. {
  13. int ans = (n + m) / 3;
  14. ans = min (ans, n);
  15. ans = min (ans, m);
  16. printf ("%d\n", ans);
  17. }
  18.  
  19. return 0;
  20. }
  21.  
  22. /*
  23. #include <cstdio>
  24. #include <algorithm>
  25. using namespace std;
  26.  
  27. int main(void)
  28. {
  29. //freopen ("C.in", "r", stdin);
  30.  
  31. int n, m;
  32.  
  33. while (~scanf ("%d%d", &n, &m))
  34. {
  35. int cnt = 0;
  36. while (n && m && (n + m) >= 3)
  37. {
  38. if (n >= m)
  39. {
  40. n -= 2; m -= 1;
  41. }
  42. else
  43. {
  44. n -=1; m -= 2;
  45. }
  46. cnt++;
  47. }
  48.  
  49. printf ("%d\n", cnt);
  50.  
  51. return 0;
  52. }
  53. */

  

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

  1. Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings

    题意: 对于26个字母 每个字母分别有一个权值 给出一个字符串,找出有多少个满足条件的子串, 条件:1.第一个字母和最后一个相同,2.除了第一个和最后一个字母外,其他的权和为0 思路: 预处理出sum ...

  2. Codeforces Round #294 (Div. 2)D - A and B and Interesting Substrings 字符串

    D. A and B and Interesting Substrings time limit per test 2 seconds memory limit per test 256 megaby ...

  3. Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题

    C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...

  4. Codeforces Round #294 (Div. 2)B - A and B and Compilation Errors 水题

    B. A and B and Compilation Errors time limit per test 2 seconds memory limit per test 256 megabytes ...

  5. Codeforces Round #294 (Div. 2)A - A and B and Chess 水题

    A. A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #294 (Div. 2) A and B and Lecture Rooms(LCA 倍增)

    A and B and Lecture Rooms time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  7. Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings [dp 前缀和 ]

    传送门 D. A and B and Interesting Substrings time limit per test 2 seconds memory limit per test 256 me ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. Spring各个jar包的简介

    spring.jar是包含有完整发布的单个jar 包,spring.jar中包含除了spring-mock.jar里所包含的内容外其它所有jar包的内容,因为只有在开发环境下才会用到 spring-m ...

  2. nyoj 20

    http://acm.nyist.net/JudgeOnline/message.php?msg=已提交&url=status.php%3Fpid%3D20&second=0 #inc ...

  3. HDOJ 1102 生成树

    Constructing Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  4. 【leetcode】Best Time to Buy and Sell Stock II

    Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a ...

  5. 初识lua

    转自:http://www.oschina.net/question/12_115993-- 两个横线是单行注释(译者注:这跟 SQL 一样) --[[ 增加两个 [ 和 ] 变成多行注释 我是多行注 ...

  6. DFS:Curling 2.0(POJ 3009)

      冰壶2.0 题目大意:就是给你一个冰壶和一个地图,地图上有石头,冰壶只能沿着x方向和y方向运动,并且要一直运动直到撞到石头为止,并且沿着此方向撞过来会把挡住的石头撞没,冰壶在停的时候可以扔出去一次 ...

  7. Java数据类型中String、Integer、int相互间的转换

    1.Integer转换成int的方法 Integer i;  int k = i.intValue(); 即Integer.intValue(); 2.int转换成Integer int i; Int ...

  8. 【mysql】执行mysql脚本

    来源:http://zhidao.baidu.com/link?url=p78PlTJZlheB4uSKCkmZApg-3qrTIBCS3yI5LbGJLEAnUuO3-4GE6dLqq1LWC_kn ...

  9. Json简介与转换数据例子

    Json是什么,Json就是javascript对象或者数组格式的字符串,Http协议不能传递JavaScript对象,所以要转换为字符串进行传输.AJAX传递复杂数据如果自己进行格式定义的话会经历组 ...

  10. 说说localStorage

    HTML5的本地存储是大势所趋,如果仅存储在内存中,则是sessionStorage,他们的语法都是一样,仅仅是一个存储在本地文件系统中,另一个存储在内存中(随着浏览器的关闭而消失),其语句如下: l ...