Educational Codeforces Round 26 A B C题
题目链接
A. Text Volume
题意:计算句子中,每个单词大写字母出现次数最多的那个的出现次数(混不混乱QAQ).
解题思路:注意getchar()就没啥了.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<ctype.h>
#include<algorithm>
using namespace std;
int main()
{
int n;
char str[];
cin>>n;
getchar();
for(int i=;i<n;i++) scanf("%c",&str[i]);
int max_len=,cnt=;
for(int i=;i<n;i++)
{
if(isalpha(str[i])>)
{
if(str[i]>='A'&&str[i]<='Z') cnt++;
}
else max_len=max(max_len,cnt),cnt=;
}
max_len=max(max_len,cnt),cnt=;
cout<<max_len<<endl;
return ;
}
B. Flag of Berland
题意:色光三原色,RGB,判断这三个字母是否都出现且围成的图案要完全一样(条纹).
解题思路:暴力模拟,扫扫扫,直接看代码吧.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char Map[][];
int n,m,x,y;
void solve(char ch)
{
int flag=;
x=y=;
for(int i=;i<n&&flag;i++)
{
for(int j=;j<m&&flag;j++)
{
if(Map[i][j]==ch)
{
flag=;
int ii=i+,jj=j+;
x++,y++;
while(Map[i][jj]==ch&&jj<m)
{
jj++; y++;
}
while(Map[ii][j]==ch&&ii<n)
{
ii++; x++;
}
for(int _i=i;_i<ii;_i++)
{
for(int _j=j;_j<jj;_j++)
if(Map[_i][_j]!=ch)
{
x=y=; return ;
}
}
}
}
}
}
int main()
{ cin>>n>>m;
for(int i=;i<n;i++) scanf("%s",Map[i]);
if( (n*m)%!= )
{
puts("NO"); return ;
}
int a=,b=,a1=,b1=,a2=,b2=;
solve('R');
a=x,b=y; solve('B');
a1=x,b1=y; solve('G');
a2=x,b2=y; if(a&&b&&a1&&b1&&a2&&b2&&a*b+a1*b1+a2*b2==n*m
&&a==a1&&a1==a2&&b==b1&&b1==b2)
puts("YES");
else puts("NO");
return ;
}
C. Two Seals
题意:在n*m纸上,盖两个印章,在不越界前提下要求总面积最大,印章可旋转着盖.
解题思路:双重for循环,直接暴力枚举,每次取一次max.
刚开始没注意到是盖两个,用背包写了半天,半路发现GG思密达...
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x[],y[];
int main()
{
int n,a,b,sum=;
cin>>n>>a>>b;
if(a>b) swap(a,b);
for(int i=;i<=n;i++) cin>>x[i]>>y[i];
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++)
{
int sumx,sumy;
sumx=x[i]+x[j],sumy=max(y[i],y[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=x[i]+y[j],sumy=max(y[i],x[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=y[i]+x[j],sumy=max(x[i],y[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=y[i]+y[j],sumy=max(x[i],x[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]);
}
cout<<sum<<endl;
return ;
}
Educational Codeforces Round 26 A B C题的更多相关文章
- Educational Codeforces Round 26
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...
- CodeForces 837F - Prefix Sums | Educational Codeforces Round 26
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...
- CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...
- CodeForces 837D - Round Subset | Educational Codeforces Round 26
/* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...
- Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]
PROBLEM D - Round Subset 题 OvO http://codeforces.com/contest/837/problem/D 837D 解 DP, dp[i][j]代表已经选择 ...
- Educational Codeforces Round 26 F. Prefix Sums 二分,组合数
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/72 ...
- Educational Codeforces Round 26 B,C
B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...
- Educational Codeforces Round 14 B. s-palindrome 水题
B. s-palindrome 题目连接: http://www.codeforces.com/contest/691/problem/B Description Let's call a strin ...
- Educational Codeforces Round 26 D dp
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
随机推荐
- lnmp vhost 虚拟目录配置
以前常用Windows 很熟悉,lnmp 配置虚拟目录也很简单. 安装完lnmp环境之后,在nginx的配置文件夹下,我采用的方法是复制default.conf 然后重命名为vhost_a.conf ...
- htmlparser学习(原创)
--thumbelina.jar 这是一个演示图片搜索和显示的小程序JFrame Preferences.userNodeForPackage(getClass()); 根据传入的class所在包 ...
- ubuntu系统中安装RoboMongo
1.下载RoboMongo RoboMongo官网下载链接.选择好相应版本. 2.解压文件 tar -xzf robomongo--linux-x86_64-.tar.gzcd robomongo-0 ...
- 2018.08.20 loj#117. 有源汇有上下界最小流(模板)
传送门 这题真有意思... 先是有一个点T的我怀疑人生. 然后学大佬们封装了我的dinic就莫名其妙的过了??? 所以说锅给谁好呢? 给dinic吧... 解法就是先求出一段可行流,然后从t到s加一条 ...
- 百度Webuploader 大文件分片上传(.net接收)
版权所有 2009-2018荆门泽优软件有限公司 保留所有权利 官方网站:http://www.ncmem.com/ 产品首页:http://www.ncmem.com/webapp/up6.2/in ...
- day4之装饰器进阶、生成器迭代器
装饰器进阶 带参数的装饰器 # 某一种情况# 500个函数加装饰器, 加完后不想再加这个装饰器, 再过一个季度,又想加上去# 你可以设计你的装饰器,来确认是否执行 # 第一种情况 # 想要500个函数 ...
- 玩转Nodejs的集群
在Nodejs中使用集群还是不容易的.Javascript的单线程属性让nodejs下的应用很难使用现代机器的多核特性.比如下面的代码实现了一个http服务器的主干部分.这部分代码只会执行在一个线程上 ...
- tornado+bootstrap急速搭建你自己的网站
bootstrap既然是这么的流行又能省很多的事为什么不用他呢?再加上牛X的produced by FB的tornado简直如虎添翼了! 1. 安装配置 安装所需要的库等内容.这里没什么需要多讲的.t ...
- java梳理-序列化与反序列化
一背景: 之前笔记关于rpc框架介绍中,提到为了调用远程服务,需要再确定消息结构后考虑序列化与反序列化,序列化主要是把对象转换成二进制码便于网络传输,反序列化就是相反的,主要目的是生成对象便于后续处理 ...
- linux下怎样用c语言调用shell命令
C程序调用shell脚本共同拥有三种法子 :system().popen().exec系列数call_exec1.c , system() 不用你自己去产生进程.它已经封装了,直接增加自己的命令 ex ...