博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #294 (Div. 2)
阅读量:7233 次
发布时间:2019-06-29

本文共 3806 字,大约阅读时间需要 12 分钟。

 

水 

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

水 

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

思路:

1. 三次排序,逐个对比(如果没找到,那个数在上一个数列的末尾)

2. 求和做差,最简单!

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

构造 

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

思路:

1. 高手加菜鸟每三个分开,在n,m的数字之内

2. 高手多,高手2;菜鸟多,菜鸟2 比较好理解

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

  

 

转载于:https://www.cnblogs.com/Running-Time/p/4366782.html

你可能感兴趣的文章
Md5加密方法
查看>>
转:zookeeper中Watcher和Notifications
查看>>
函数的参数
查看>>
Java编程规范
查看>>
【洛谷 P1070】道路游戏 (DP)
查看>>
走迷宫(回溯、深搜)判断能否到终点
查看>>
Zookeeper权限管理与Quota管理
查看>>
CORS 详解
查看>>
【原】iOS学习之苹果原生代码实现Autolayout和VFL语言
查看>>
ASP.NET MVC中使用FluentValidation验证实体
查看>>
usb mass storage device
查看>>
CentOs7
查看>>
python3封装Api接口
查看>>
jar包双击执行引用外部包问题
查看>>
OI复习计划
查看>>
about
查看>>
O-Bomb(数位dp)
查看>>
hdu5032 点和查询分别按极角排序 离线做+树状数组
查看>>
hdu1428 递归形式dp(记忆化搜素):A能到B的条件是A到目的地最短路大于B到目的地最短路...
查看>>
实例详解Django的 select_related 和 prefetch_related 函数对 QuerySet 查询的优化(三)...
查看>>