日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #294 (Div. 2)

發(fā)布時(shí)間:2024/4/17 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #294 (Div. 2) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

水?A. A and B and Chess

/*水題 */ #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

題意:三組數(shù)列,依次少一個(gè),找出少了的兩個(gè)數(shù)

思路:

1. 三次排序,逐個(gè)對(duì)比(如果沒找到,那個(gè)數(shù)在上一個(gè)數(shù)列的末尾)
2. 求和做差,最簡(jiǎn)單!

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

構(gòu)造?C. A and B and Team Training

題意:方案:高手1和菜鳥2 或者 高手2菜鳥1 三人組隊(duì)求最大組隊(duì)數(shù)
思路:

1. 高手加菜鳥每三個(gè)分開,在n,m的數(shù)字之內(nèi)
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; } */

  

?

轉(zhuǎn)載于:https://www.cnblogs.com/Running-Time/p/4366782.html

總結(jié)

以上是生活随笔為你收集整理的Codeforces Round #294 (Div. 2)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。