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. Oracle分区表例子

    分区表 Oracle提供的分区方法有以下几种. 1.范围分区(range) 范围分区是应用范围比较广的表分区方式,它是以列的值的范围来作为分区的划分条 件,将记录存放到列值所在的 range分区中. ...

  2. MySQL+PHP配置 Windows系统IIS版

    MySQL+PHP配置 Windows系统IIS版 1.下载 MySQL下载地址:http://dev.mysql.com/downloads/mysql/5.1.html->Windows ( ...

  3. GCC的函数声明问题

    Thinking in C++ 第四章 GCC 不需要再MAIN函数前声明 编译也能通过. G++不行.

  4. iOS Programming Auto Layout: Programmatic Constraints 自动布局:通过编程限制

    iOS Programming  Auto Layout: Programmatic Constraints  1.  However, if your views are created in co ...

  5. 阿里云设置指定ip访问实例

    添加安全组规则 添加允许访问的外网IP,优先级设置为1,并将所有ip设置为拒绝访问,优先级设置为2. 参考地址: https://help.aliyun.com/document_detail/254 ...

  6. Javaweb项目构建常见问题

    eclipse中 将java项目转换为web项目 1.找到项目工作空间目录,打开.project文件,并修改文件, 修改如下:      找到:<natures> </natures ...

  7. oauth 理解

    单点登录 对授权码模式的解读. 1. 用户访问客户端,客户端将请求认证服务器. 2. 用户选择是否给予客户端授权 3.用户授权后,认证服务器将用户导向客户端事先定义好的重定向的地址,同时会附上一个授权 ...

  8. C# 获取目录下文件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. ALTER FUNCTION - 修改一个函数的定义

    SYNOPSIS ALTER FUNCTION name ( [ type [, ...] ] ) RENAME TO newname DESCRIPTION 描述 ALTER FUNCTION 修改 ...

  10. CAD使用GetAllAppName读所有名称(com接口)

    主要用到函数说明: MxDrawEntity::GetAllAppName 得到所有扩展数据名称,详细说明如下: 参数 说明 [out, retval] IMxDrawResbuf** ppRet 返 ...