• 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;
    }
    
  • 相关阅读:
    原型设计
    案例分析
    编程作业
    《构建之法》阅读任务
    2021.3.11 准备工作随笔
    课程总结
    第十四周课程总结&实验报告(简单记事本的实现)
    第十三周课程总结
    第十二周
    第十一周课程总结
  • 原文地址:https://www.cnblogs.com/Tuesdayzz/p/5758768.html
Copyright © 2020-2023  润新知