A. Far Relative’s Birthday Cake

题意:

求在同一行、同一列的巧克力对数。

分析:

水题~样例搞明白再下笔!

代码:

#include<iostream>
using namespace std;
const int maxn = 105;
char a[maxn][maxn];
int main (void)
{
int N;cin>>N;
int cnt = 0, res = 0;
for(int i = 0; i < N; i++){
cnt = 0;
for(int j = 0; j < N; j++){
cin>>a[i][j];
if(a[i][j]=='C') cnt++;
}
res += cnt * (cnt - 1)/2;
}
for(int j = 0; j < N; j++){
cnt = 0;
for(int i = 0; i <N; i++){
if(a[i][j]=='C')
cnt++;
}
res += cnt * (cnt - 1)/2;
}
cout<<res<<endl;
return 0;
}

B. Far Relative’s Problem

题意:

给定男生女生的空余时间,求出满足在该天空余的男生数与女生数相等且人数最多的一天。

分析:

白痴的WA了一次。。。直接暴力

代码:

#include<iostream>
#include<cmath>
using namespace std;
const int maxn = 5005, maxm = 400;
int cnt[maxm], flag[maxm];
int main (void)
{
int N;cin>>N;
char a;
int b ,c, l = 400, r = 0;
for(int i = 0; i < N; i++){
cin>>a>>b>>c;
for(int j = b; j <= c; j++){
cnt[j]++;
if(a=='M') flag[j]++;
else flag[j]--;
} }
int res = 0;
for(int i = 1; i <= 366; i++){
if(flag[i]!=0) cnt[i] -= abs(flag[i] - 0);
if(res<cnt[i]) res = cnt[i];
}
cout<<res<<endl;
}

Codeforces Round #343 (Div. 2)【A,B水题】的更多相关文章

  1. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  2. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  3. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  4. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  5. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  6. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  7. Codeforces Round #340 (Div. 2) D. Polyline 水题

    D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...

  8. Codeforces Round #338 (Div. 2) A. Bulbs 水题

    A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...

  9. Codeforces Round #282 (Div. 1) A. Treasure 水题

    A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...

  10. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

随机推荐

  1. PHP + ORACLE 远程连接数据库环境配置

    在ORACLE官网下载instantclient_11_2,放在D盘 把instantclient_11_2目录下的所有dll文件复制到C:\Windows\SysWOW64   和  D:\phpS ...

  2. 微软2017年预科生计划在线编程笔试 A Legendary Items

    思路: 获得第i(i = 0, 1, ..., n - 1)件物品的概率仅由公式p / (1 << i)决定,所以获得这i件物品之间是相互独立的.迭代计算获得所有i件物品的期望再求和即可. ...

  3. Spring-----注解开发和Spring测试单元

    一.注解开发 导入jar包;spring-aop-xxx.jar 导入约束:(在官方文档xsd-configuration.html可找) <beans xmlns="http://w ...

  4. 学习笔记 第十五章 JavaScript基础

    第15章   JavaScript基础 [学习重点] 了解JavaScript基础知识 熟悉常量和变量 能够使用表达式和运算符 正确使用语句 能够掌握数据类型和转换的基本方法 正确使用函数.对象.数组 ...

  5. 掌握Spark机器学习库-06-基础统计部分

    说明 本章主要讲解基础统计部分,包括基本统计.假设检验.相关系数等 数据集 数据集有两个文件,分别是: beijing.txt 北京历年降水量,不带年份 beijing2.txt 北京历年降水量,带年 ...

  6. (转)淘淘商城系列——SSM框架整合之Service层整合

    http://blog.csdn.net/yerenyuan_pku/article/details/72721108 上文我们一起学习了Dao层的整合,本文将教大家如何整合Service层. 我们需 ...

  7. 「 Luogu P1122 」 最大子树和

    # 题目大意 真讨厌题面写的老长老长的. 这个题的意思就是给定一棵无根树,每个节点都有一个美丽值(可能是负数),可以删掉一些边来删除某些点,现在要求你求出可以删掉任意条边的情况下,这个树上的剩余节点的 ...

  8. 20181225模拟赛 T1 color (转化思想,分拆思想)

    题目: 有⼀块有 n 段的栅栏,要求第 i 段栅栏最终被刷成颜色 ci .每⼀次可以选择 l, r 把第l . . . r 都刷成某种颜色,后刷的颜⾊会覆盖之前的.⼀共有 m 种颜色,雇主知道只需要用 ...

  9. 懒癌晚期学图论的时候自己用C语言写了个求可达性矩阵的算法~

    可达性矩阵算法~ 直接上代码 #include <iostream> #include <cstring> using namespace std; #define n 5 v ...

  10. LG-P1311选择客栈

    题目 暴力十分好想但你写不出来qwq 正解十分好写但你想不出来qaq 我们先读题,发现k其实没什么用 同时暴力枚举两个客栈的话会超时,所以只能同时枚举一个.我们枚举第二个客栈,然后用第二个客栈反推出前 ...