CodeForces 688AOpponents

来源:互联网 发布:跑步路线规划软件 编辑:程序博客网 时间:2024/06/06 04:41

题目链接:http://codeforces.com/problemset/problem/688/A

题目大意:如果一行数字全是1失败,有0则成功,求最大成功次数

简单的水题。。。

代码如下:

#include<algorithm>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<iostream>using namespace std;int main(){ int a, b;    int sum = 0, cnt = 0;    scanf("%d%d",&a, &b);    for(int i = 0; i < b; i++)    {        char c[1005] = {0};        scanf("%s", c);        int  f= 0;        for(int j = 0; j < a; j++)        {            if(c[j] == '0')            {                f = 1;                break;            }        }        if(f==1)            cnt++;        else            cnt=0;        sum=max(sum,cnt);    }    printf("%d\n",sum);}

0 0
原创粉丝点击