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;
    }
    
  • 相关阅读:
    操作~拷贝clone()
    属性/css~储存
    属性/css~位置.offset()&offsetParent()&position()&scrollTop()&scrollLeft()
    属性/css~尺寸.height()
    设置,获取,删除cookie方法
    Cookie
    属性/css~css.css()
    Python井字游戏
    Asp.net vNext 学习之路(三)
    使用C#发送Http 请求实现模拟登陆(以博客园为例)
  • 原文地址:https://www.cnblogs.com/forward-985/p/13911062.html
Copyright © 2011-2022 走看看