zoukankan      html  css  js  c++  java
  • Codeforces Round #343 (Div. 2)【A,B水题】

    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;
    }
    
  • 相关阅读:
    framework7 底部弹层popup js关闭方法
    div动画旋转效果
    面试题3
    面试题2
    CORS跨域请求[简单请求与复杂请求]
    面试题1
    nginx
    Pycharm配置支持vue语法
    Ajax在jQuery中的应用---加载异步数据
    jQuery开发入门
  • 原文地址:https://www.cnblogs.com/Tuesdayzz/p/5758768.html
Copyright © 2011-2022 走看看