zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    单位
    北京户口
    中科院助理工程师
    SQL学习
    question
    ROI选取过程
    IT学习网站
    撞库 拖库
    善用人类记忆的特点去高效学习
    为什么散步对健康很有益处
  • 原文地址:https://www.cnblogs.com/forward-985/p/13911062.html
Copyright © 2011-2022 走看看