CodeForces 688A-Opponents
题意:
Arya在学校有n个敌人(一串含有0,1的数字表示),有一个游戏规则,如果当天这n个敌人全部出席("1"代表出席,),即这串数字全部为"1",则Arya就输了,
否则,只要其中就一个"0",代表Arya赢,问你他连续赢得最多的天数?
分析:
初始化ans(连续赢得最多的天数)为0,Arya连续赢天数day就加1,否则比较day与ans大小,ans = max(ans, day);
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 int main()
{
int d;
int n;
int cnt, flag, pos;
while(cin>>n>>d)
{
string s;
int i, j;
pos = 0;
cnt = 0;
for(i = 1; i <= d; i++ )
{
flag = 0;
cin>>s;
for(j = 0; j < n; j++ )
{
if(s[j]-'0' == 0)
{
flag = 1;
break;
}
}
if(flag)
{
cnt += 1;
pos = max(pos, cnt);
}
else
cnt = 0;
}
printf("%d\n", pos);
}
return 0;
}
CodeForces 688A-Opponents的更多相关文章
- CodeForces 688A Opponents (水题)
题意:给定 n 行数,让你找出连续最多的全是1的个数. 析:好像也没什么可说的,那就判断一下,并不断更新最大值呗. 代码如下: #include <iostream> #include & ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律
Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- [Codeforces Round #192 (Div. 2)] D. Biridian Forest
D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...
- Codeforces Round #468 Div. 2题解
A. Friends Meeting time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
随机推荐
- android 消息机制
一.Android应用程序的主线程主要用于更新UI界面,并且主线程不能做耗时操作,否则会引起ANR:这种情况下需要开一个子线程来进行耗时操作,动作完成之后,子线程发消息给主线程通知其更新UI显示,常见 ...
- 在C#中??和?分别是什么意思?
在C# 6.0中,引入了一个 ?. 的运算符,前面的代码可以改成如下形式: int? firstX = points?.FirstOrDefault()?.X; 从这个例子中我们也可以看出它的基本用法 ...
- DirectUI 收集资料
1.[ZsUI]一步一步写个DirectUI.[连载贴] (http://tieba.baidu.com/p/1625954225) ps: 虽然是vb写的,也很简陋,不过有代码,并且作者每节都给出了 ...
- How to use usercontrol - pass paramters
在线PhotoShop http://uupoop.com/ In the previous chapter we created a UserControl, and now we will try ...
- C# 的Brush 及相关颜色的操作 (并不是全转)
C# 的Brush 及相关颜色的操作 2013-12-13 14:08 4977人阅读 评论(0) 收藏 ...
- PHP Socket 编程过程详解
使用代码 目的:开发一个客户端用于发送string消息到服务端,服务端将相同的信息反转后返回给客户端. PHP服务器 第1步:设置变量,如“主机”和“端口” $host = "127.0.0 ...
- js页面刷新之实现框架内外刷新(整体、局部)
这次总结的是框架刷新: 框架内外的按钮均可以定义网页重定向, 框架内部页面的按钮可以实现局部刷新, 框架外部页面的按钮可以实现整页刷新. 代码如下(两个html页面): <!--主界面index ...
- SPOJ 375. Query on a tree (树链剖分)
Query on a tree Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on SPOJ. Ori ...
- [问题2015S04] 复旦高等代数 II(14级)每周一题(第五教学周)
[问题2015S04] 设 \(A\) 为 \(n\) 阶方阵, \(C\) 为 \(k\times n\) 矩阵, 且对任意的 \(\lambda\in\mathbb{C}\), \(\begin{ ...
- Mifare系列1-简介(转)
文章转自 文/闫鑫原创转载请注明出处http://blog.csdn.net/yxstars/article/details/38079827 感谢原创作者的辛勤,对您再次表达感谢! 随着社会的发展, ...