• Codeforces Round #677 (Div. 3)【ABCDE】


    比赛链接:https://codeforces.com/contest/1436

    A.Reorder

    题解

    经过模拟计算,观察到
    (sum_{i=1}^n sum_{j=i}^n frac{a_j}{j}=sum_{i=1}^n a_i)
    判断每个n个数的和sum与m是否相等即可s

    代码

    #include<iostream>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    int main()
    {
        ios::sync_with_stdio(false);//关闭cin与scanf同步
        cin.tie(nullptr);
        int t;cin>>t;
        while(t--)
        {
            int n,m,x,sum=0;
            cin>>n>>m;
            for(int i=0;i<n;i++)
            {
                cin>>x;
                sum+=x;
            }
            if(sum==m)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
        return 0;
    }
    

    B.Yet Another Bookshelf

    题解

    代码

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t;
        cin >> t;
        while (t--) {
            int n, m;
            cin >> n >> m;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int x;
                cin >> x;
                sum += x;
            }
            cout << (sum == m ? "YES" : "NO") << "
    ";
        }
        return 0;
    }
    

    A.Reorder

    题解

    代码

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t;
        cin >> t;
        while (t--) {
            int n, m;
            cin >> n >> m;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int x;
                cin >> x;
                sum += x;
            }
            cout << (sum == m ? "YES" : "NO") << "
    ";
        }
        return 0;
    }
    

    A.Reorder

    题解

    代码

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t;
        cin >> t;
        while (t--) {
            int n, m;
            cin >> n >> m;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int x;
                cin >> x;
                sum += x;
            }
            cout << (sum == m ? "YES" : "NO") << "
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    AWS EC2 优化 CPU 选项
    chrome 向群组中添加标签页
    Hadoop中TeraSort算法分析
    hadoop —— teragen & terasort
    spark本地读取写入s3文件
    将 Spark Streaming 的结果保存到 S3
    ipython notesbook 默认路径修改
    Python操作MongoDB
    python读取excel,数字都是浮点型,日期格式是数字的解决办法
    flask-profiler的使用
  • 原文地址:https://www.cnblogs.com/forward-985/p/13911062.html
Copyright © 2020-2023  润新知