/* 水题 */ #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; } */