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. outlook 通讯录分类--2017年1月16日--对联系人分类管理

    outlook功能多,复杂,导致打开界面就晕,通讯录分类 问:在Outlook 中,随着联系人数量的增多,亲朋好友.同事.客户的信息混杂在一起,每次发邮件都要用很长时间才能从联系人列表中找到需要的人. ...

  2. 原创 SqlParameter 事务 批量数据插入

    不错,很好,以后防注入批量事务提交虽然麻烦点研究了几个小时,但不会是问题了 SqlCommand cmd; HelpSqlServer helps = new HelpSqlServer(); //定 ...

  3. shell编写的多服务器自动互信脚本(安装ceph)

    相信大家都使用过分布式存储,而在分布式存储中较为出色的非ceph莫属了,但是这里就不深入聊ceph啦,我们只是聊聊安装ceph时遇到的问题. ceph需要多台主机进行ssh互信.三台还能忍受,但是当超 ...

  4. Objective -C Categories

    Objective -C Categories  The dynamic runtime dispatch mechanism employed by Objective-C lets you add ...

  5. Laravel Mix编译前端资源

    目前项目是使用的vue+laravel来写的,其中laravel和vue分别放了一个目录,但是这样有个问题,那就是vue需要经常更新,不然运行项目会经常出现各种问题,这里就看了看laravel的文档, ...

  6. MFC_VS清理器

    VS清理器 界面 工程目录 列表控件ID改名IDC_FILELIST 绑定变量m_FileList 属性设置Accept Files 设置True 成员添加 // 用于保存待遍历的目录 vector& ...

  7. 【转】c语言中的定义和声明

    1. 变量的定义.声明 变量的声明有两种情况: 一种是需要建立存储空间的.例如:int  a.在声明的时候就已经建立了存储空间.这种声明是"定义性声明(defining declaratio ...

  8. Spring全局异常捕获

    package org.xxx.ac.zpk.exception; import java.io.IOException; import javax.servlet.http.HttpServletR ...

  9. mac 下安装python pil

    mac:sudo brew install freetype sudo pip install pillow ubuntu: sudo apt-get install libfreetype6-dev ...

  10. 浅谈Session的使用(原创)

    目录 浅谈Session的使用(原创) 1.引言 2.Session域的生命周期 2.1 Session的创建 2.2 Session的销毁 3.那么,session被销毁后,其中存放的属性不就都访问 ...