CodeForces 688A Opponents (水题)
题意:给定 n 行数,让你找出连续最多的全是1的个数。
析:好像也没什么可说的,那就判断一下,并不断更新最大值呗。
代码如下:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string> using namespace std;
typedef long long LL;
string s; int main(){
int n, d, cnt = 0;
bool ok = false;
int m = -1;
scanf("%d %d", &n, &d);
for(int i = 0; i < d; ++i){
cin >> s;
int j;
for(j = 0; j < n; ++j)
if(s[j] != '1') break; if(ok && j != n) ++cnt;
else if(j != n){ ok = true; cnt = 1; }
else{ cnt = 0; ok = false; }
m = max(m ,cnt);
}
printf("%d\n", m);
return 0;
}
CodeForces 688A Opponents (水题)的更多相关文章
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces数据结构(水题)小结
最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...
- CodeForces 705A Hulk (水题)
题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...
- CodeForces 705B (训练水题)
题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2) ...
- codeforces hungry sequence 水题
题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...
- codeforces 377A. Puzzles 水题
A. Puzzles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/33 ...
- CodeForces 474B Worms (水题,二分)
题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc+ ...
- CodeForces - 682B 题意水题
CodeForces - 682B Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — ...
随机推荐
- MyEclipse部署项目到Tomcat上,但是classes文件夹下没有编译项目
在MyEclipse中把项目部署到Tomcat上,但是Tomcat下的classes文件夹下没有编译项目解决方法:1-直接在点击菜单栏的Project--clean,对项目进行clean2-查看菜单栏 ...
- Phonegap下localStorage使用实践
HTML5的Web Storage API提供了两种客户端存储数据的方法 localStorage和sessionStorage. localStorage没有时间限制,程序升级也不会消失,可以满足持 ...
- Mysql向存储过程中传递中文参数变成乱码的解决方案
今天做程序需要用到一个存储过程,然后用php程序调用. 存储过程如下: delimiter $$ CREATE PROCEDURE disagree_upgrade_detail(a int,b t ...
- 详解Centos7 修改mysql指定用户的密码
本文介绍了Centos7 修改mysql指定用户的密码,具体如下: 1.登陆mysql或者mariadb(两种任选其一) [root@localhost ~]# mysql -u root [root ...
- XP IE8 安装失败
装完XP后,此时是IE6.装了QQ浏览器,提示会锁定浏览器主页,没怎么在意. 然后装IE8时,提示失败. 在网上搜索了下是其它浏览器或程序锁定了浏览器主页.卸载QQ浏览器后,成功安装IE8.
- Python VIL Service Bin
#!/usr/bin/python #coding:UTF-8 import sys import re import getopt import md5 import os import subpr ...
- elasticsearch RESTful
一 .索引(index) 1. 创建索引 (1)第一种方式 PUT twitter { "settings" : { "index" : { "num ...
- POJ 1258 Agri-Net (prim水题)
Agri-Net Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total Subm ...
- 常见的加密和解密算法—AES
一.AES加密概述 高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准.这个标准用 ...
- SPM——How to use github
In this semester, we take a class called 'Software Project Management'. And in this class, we have l ...