zoukankan      html  css  js  c++  java
  • 【cf比赛记录】Educational Codeforces Round 77 (Rated for Div. 2)

    比赛传送门

    这场题目前三题看得挺舒服的,没有臃肿的题目,对于我这种英语渣渣就非常友好,但因为太急了,wa了两发A后才意识到用模拟(可以删了,博主真的是个菜鸟),结果导致心态大崩 ---- 而且也跟最近的生活学习有点关系 ----补了B,跟C题。B题还是有点可惜的,没有做出来。

    A

    // http://codeforces.com/contest/1260/problem/A
    /*
        因为可以把 sum 分成 c 份(每份可以用 0 来补充)
        所以要想最小,可以直接取接近中间值的数再平方
        下面用模拟实现
    */
    #include<iostream>
    #include<cstdio>
    using namespace std;
    
    int n;
    int c, sum;
    
    int main()
    {
        scanf("%d", &n);
        while(n--){
            scanf("%d %d", &c, &sum);
            if(c >= sum){
                printf("%d
    ", sum);
            }
            else if(c == 1){
                printf("%d
    ", sum * sum);
            }
            else {
                int ans = 0;
                while(c > 0){
                    int d = sum / c;
                    ans += d * d;
                    c--;
                    sum -= d;
                }
                printf("%d
    ", ans);
            }
        }
        return 0;
    }
    
    

    B

    // http://codeforces.com/contest/1260/problem/B
    /*
        分析:
        若
            a = x_1 + x_2 + ... + x_k
        则  b = 2 * x_1 + 2 * x_2 + ... + 2 * x_k = 2 * (x_1 + x_2 + ... + x_k) = 2 * a
        由此可以看出 ---- 若输出 YES b 的最大值为 2a
        所以有条件一 a * 2 >= b ①
        a + b = 3 * (x_1 + x_2 + ... + x_k)
        可见 (a + b) % 3 == 0  ②
    */
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    
    int n, a, b;
    
    int main()
    {
        scanf("%d", &n);
        while(n--){
            scanf("%d %d", &a, &b);
            if(a > b) swap(a, b); // 保证 b > a
            if((a + b) % 3 == 0 && a * 2 >= b) printf("YES
    ");
            else printf("NO
    ");
        }
        return 0;
    }
    
    

    C

    // https://codeforces.com/contest/1260/problem/C
    /*
        题意:给木板涂色,要求不能有连续 k 块的颜色一样(没有涂色的木板不计入)
        知识点 ---- gcd(int, int) 求两数的最大公约数
        当 gcd(r, b) == 1 时(即两数互为质数), 当 r b 相近的时候,如果先涂了r,那么下一个就是 b
        此时,要检查 r b 二者差距是否过大 ---- 即要符合
        (k - 1) * r + 1 >= b 即连续的第 k-1 格上涂的 r 会比前面一格(因为 gcd() == 1)要大于等于 b
        所以,对于 gcd(r, b) > 1 时只需要把它们都除以自己的最大公约数就可以互为质数了
        注意会爆 int 范围
    */
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    
    typedef long long LL;
    LL T, r, b, k;
    
    LL gcd(LL a, LL b){
        if(b == 0) return a;
        else return gcd(b, a % b);
    }
    
    int main()
    {
        scanf("%I64dd", &T);
        while(T--){
            scanf("%I64d %I64d %I64d", &r, &b, &k);
            if(r > b) swap(r, b);
            LL d = gcd(b, r);
            b /= d; r /= d;
            if((k - 1) * r + 1 >= b){
                printf("OBEY
    ");
            }
            else printf("REBEL
    ");
        }
        return 0;
    }
    
    

    掉分了

  • 相关阅读:
    HDU 1058 Humble Numbers
    HDU 1160 FatMouse's Speed
    HDU 1087 Super Jumping! Jumping! Jumping!
    HDU 1003 Max Sum
    HDU 1297 Children’s Queue
    UVA1584环状序列 Circular Sequence
    UVA442 矩阵链乘 Matrix Chain Multiplication
    DjangoModels修改后出现You are trying to add a non-nullable field 'download' to book without a default; we can't do that (the database needs something to populate existing rows). Please select a fix:
    opencv做的简单播放器
    c++文件流输入输出
  • 原文地址:https://www.cnblogs.com/Ayanowww/p/11960039.html
Copyright © 2011-2022 走看看