Codeforces Round #294 (Div. 2)
- /*
- 水题
- */
- #include <cstdio>
- #include <algorithm>
- #include <iostream>
- #include <cstring>
- #include <string>
- using namespace std;
- const int maxn = 1e6 + 10;
- int a[maxn];
- int main(void)
- {
- //freopen ("A.in", "r", stdin);
- string s1;
- int suma = 0; int sumb = 0;
- for (int i=1; i<=8; ++i)
- {
- cin >> s1;
- for (int j=0; s1[j]!='\0'; ++j)
- {
- if (s1[j] == '.') continue;
- else if (s1[j] == 'Q') suma += 9;
- else if (s1[j] == 'R') suma += 5;
- else if (s1[j] == 'B') suma += 3;
- else if (s1[j] == 'N') suma += 3;
- else if (s1[j] == 'P') suma += 1;
- else if (s1[j] == 'q') sumb += 9;
- else if (s1[j] == 'r') sumb += 5;
- else if (s1[j] == 'b') sumb += 3;
- else if (s1[j] == 'n') sumb += 3;
- else if (s1[j] == 'p') sumb += 1;
- }
- }
- if (suma > sumb) cout << "White" << endl;
- else if (suma < sumb) cout << "Black" << endl;
- else cout << "Draw" << endl;
- return 0;
- }
水 B. A and B and Compilation Errors
题意:三组数列,依次少一个,找出少了的两个数
思路:
1. 三次排序,逐个对比(如果没找到,那个数在上一个数列的末尾)
2. 求和做差,最简单!
- #include <cstdio>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- const int maxn = 1e5 + 10;
- int a[maxn];
- int b[maxn];
- int c[maxn];
- int main(void)
- {
- //freopen ("B.in", "r", stdin);
- int n, x, y;
- while (~scanf ("%d", &n))
- {
- x = y = 0;
- for (int i=1; i<=n; ++i)
- {
- scanf ("%d", &a[i]);
- }
- sort (a+1, a+1+n);
- for (int i=1; i<=n-1; ++i)
- {
- scanf ("%d", &b[i]);
- }
- sort (b+1, b+1+n-1);
- for (int i=1; i<=n-1; ++i)
- {
- if (a[i] == b[i]) continue;
- else
- {
- x = a[i];
- break;
- }
- }
- if (x == 0) x = a[n];
- for (int i=1; i<=n-2; ++i)
- {
- scanf ("%d", &c[i]);
- }
- sort (c+1, c+1+n-2);
- for (int i=1; i<=n-2; ++i)
- {
- if (b[i] == c[i]) continue;
- else
- {
- y = b[i];
- break;
- }
- }
- if (y == 0) y = b[n-1];
- printf ("%d\n%d\n", x, y);
- }
- return 0;
- }
- /*
- #include <cstdio>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- const int maxn = 1e5 + 10;
- int a[maxn];
- int b[maxn];
- int c[maxn];
- int suma, sumb, sumc;
- int main(void)
- {
- //freopen ("B.in", "r", stdin);
- int n;
- while (~scanf ("%d", &n))
- {
- suma = sumb = sumc = 0;
- for (int i=1; i<=n; ++i)
- {
- scanf ("%d", &a[i]); suma += a[i];
- }
- for (int i=1; i<=n-1; ++i)
- {
- scanf ("%d", &b[i]); sumb += b[i];
- }
- for (int i=1; i<=n-2; ++i)
- {
- scanf ("%d", &c[i]); sumc += c[i];
- }
- printf ("%d\n%d\n", suma - sumb, sumb - sumc);
- }
- return 0;
- }
- */
构造 C. A and B and Team Training
题意:方案:高手1和菜鸟2 或者 高手2菜鸟1 三人组队求最大组队数
思路:
1. 高手加菜鸟每三个分开,在n,m的数字之内
2. 高手多,高手2;菜鸟多,菜鸟2 比较好理解
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- int main(void)
- {
- //freopen ("C.in", "r", stdin);
- int n, m;
- while (~scanf ("%d%d", &n, &m))
- {
- int ans = (n + m) / 3;
- ans = min (ans, n);
- ans = min (ans, m);
- printf ("%d\n", ans);
- }
- return 0;
- }
- /*
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- int main(void)
- {
- //freopen ("C.in", "r", stdin);
- int n, m;
- while (~scanf ("%d%d", &n, &m))
- {
- int cnt = 0;
- while (n && m && (n + m) >= 3)
- {
- if (n >= m)
- {
- n -= 2; m -= 1;
- }
- else
- {
- n -=1; m -= 2;
- }
- cnt++;
- }
- printf ("%d\n", cnt);
- return 0;
- }
- */
Codeforces Round #294 (Div. 2)的更多相关文章
- Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings
题意: 对于26个字母 每个字母分别有一个权值 给出一个字符串,找出有多少个满足条件的子串, 条件:1.第一个字母和最后一个相同,2.除了第一个和最后一个字母外,其他的权和为0 思路: 预处理出sum ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- Spring各个jar包的简介
spring.jar是包含有完整发布的单个jar 包,spring.jar中包含除了spring-mock.jar里所包含的内容外其它所有jar包的内容,因为只有在开发环境下才会用到 spring-m ...
- nyoj 20
http://acm.nyist.net/JudgeOnline/message.php?msg=已提交&url=status.php%3Fpid%3D20&second=0 #inc ...
- HDOJ 1102 生成树
Constructing Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 【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 ...
- 初识lua
转自:http://www.oschina.net/question/12_115993-- 两个横线是单行注释(译者注:这跟 SQL 一样) --[[ 增加两个 [ 和 ] 变成多行注释 我是多行注 ...
- DFS:Curling 2.0(POJ 3009)
冰壶2.0 题目大意:就是给你一个冰壶和一个地图,地图上有石头,冰壶只能沿着x方向和y方向运动,并且要一直运动直到撞到石头为止,并且沿着此方向撞过来会把挡住的石头撞没,冰壶在停的时候可以扔出去一次 ...
- Java数据类型中String、Integer、int相互间的转换
1.Integer转换成int的方法 Integer i; int k = i.intValue(); 即Integer.intValue(); 2.int转换成Integer int i; Int ...
- 【mysql】执行mysql脚本
来源:http://zhidao.baidu.com/link?url=p78PlTJZlheB4uSKCkmZApg-3qrTIBCS3yI5LbGJLEAnUuO3-4GE6dLqq1LWC_kn ...
- Json简介与转换数据例子
Json是什么,Json就是javascript对象或者数组格式的字符串,Http协议不能传递JavaScript对象,所以要转换为字符串进行传输.AJAX传递复杂数据如果自己进行格式定义的话会经历组 ...
- 说说localStorage
HTML5的本地存储是大势所趋,如果仅存储在内存中,则是sessionStorage,他们的语法都是一样,仅仅是一个存储在本地文件系统中,另一个存储在内存中(随着浏览器的关闭而消失),其语句如下: l ...