zoukankan      html  css  js  c++  java
  • dut新生大礼包3

    A

    https://atcoder.jp/contests/abc177/tasks/abc177_c?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    const int P = 1000000007;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n;
        cin >> n;
    
        vector<int> a(n);
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
        }
    
        long long ans = 0;
        long long sum = 0;
        for(int i = 0; i < n; ++i) {
            ans = (ans + sum * a[i]) % P;
            sum = (sum + a[i]) % P;
        }
    
        cout << ans << '
    ';
    
        return 0;
    }
    View Code

    B

    https://atcoder.jp/contests/abc177/tasks/abc177_d?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n, m;
        cin >> n >> m;
    
        vector<vector<int> > G(n);
        for(int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            G[a].emplace_back(b);
            G[b].emplace_back(a);
        }
    
        vector<bool> vis(n);
    
        int ans = 0;
        for(int i = 0; i < n; ++i) {
            if(!vis[i]) {
                int cnt = 0;
                queue<int> q;
                q.emplace(i);
                vis[i] = true;
                while(!q.empty()) {
                    int u = q.front();
                    q.pop();
                    cnt += 1;
                    for(int v : G[u]) {
                        if(!vis[v]) {
                            vis[v] = true;
                            q.emplace(v);
                        }
                    }
                }
                ans = max(ans, cnt);
            }
        }
    
        cout << ans << '
    ';
    
        return 0;
    }
    View Code

    C

    https://atcoder.jp/contests/abc183/tasks/abc183_c?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        int n, k;
        cin >> n >> k;
    
        vector<vector<int> > t(n, vector<int> (n));
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                cin >> t[i][j];
            }
        }
    
        vector<int> id(n);
        iota(id.begin(), id.end(), 0);
    
        int ans = 0;
    
        do {
            int sum = 0;
            for(int i = 0; i < n; ++i) {
                sum += t[id[i]][id[(i + 1) % n]];
            }
            if(sum == k) {
                ans += 1;
            }
        } while(next_permutation(id.begin(), id.end()));
    
        cout << ans / n << '
    ';
    
        return 0;
    }
    View Code

    D

    https://atcoder.jp/contests/abc183/tasks/abc183_d?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n, w;
        cin >> n >> w;
    
        vector<int> s(n);
        vector<int> t(n);
        vector<int> p(n);
        for(int i = 0; i < n; ++i) {
            cin >> s[i] >> t[i] >> p[i];
        }
    
        vector<long long> sum(200001);
        for(int i = 0; i < n; ++i) {
            sum[s[i]] += p[i];
            sum[t[i]] -= p[i];
        }
    
        for(int i = 0; i < 200000; ++i) {
            sum[i + 1] += sum[i];
        }
    
        if(*max_element(sum.begin(), sum.end()) > w) {
            cout << "No" << '
    ';
        } else {
            cout << "Yes" << '
    ';
        }
    
        return 0;
    }
    View Code

    E

    https://atcoder.jp/contests/abc182/tasks/abc182_c?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        long long n;
        cin >> n;
    
        vector<int> b;
        while(n) {
            b.emplace_back(n % 10);
            n /= 10;
        }
    
        int m = b.size();
        int ans = m;
        for(int i = 0; i < 1 << m; ++i) {
            int sum = 0;
            for(int j = 0; j < m; ++j) {
                if(i >> j & 1) {
                    sum += b[j];
                }
            }
            if(sum % 3 == 0) {
                ans = min(ans, m - __builtin_popcount(i));    
            }
        }
    
        if(ans == m) {
            cout << -1 << '
    ';
        } else {
            cout << ans << '
    ';
        }
    
        return 0;
    }
    View Code

    F

    https://atcoder.jp/contests/abc182/tasks/abc182_d?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n;
        cin >> n;
    
        vector<int> a(n);
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
        }
    
        vector<long long> pre(n + 1);
        vector<long long> mx(n + 1);
        for(int i = 0; i < n; ++i) {
            pre[i + 1] = pre[i] + a[i];
            mx[i + 1] = max(mx[i], pre[i + 1]);
        }
    
        long long cur = 0;
        long long ans = 0;
        for(int i = 1; i <= n; ++i) {
            ans = max(ans, cur + mx[i]);
            cur += pre[i];
        }
    
        cout << ans << '
    ';
    
        return 0;
    }
    View Code

    G

    https://atcoder.jp/contests/abc180/tasks/abc180_c?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        long long n;
        cin >> n;
    
        vector<long long> ans;
        for(long long i = 1; i * i <= n; ++i) {
            if(n % i == 0) {
                ans.emplace_back(i);
                ans.emplace_back(n / i);
            }
        }
    
        sort(ans.begin(), ans.end());
        ans.erase(unique(ans.begin(), ans.end()), ans.end());
    
        for(long long i : ans) {
            cout << i << '
    ';
        }
    
        return 0;
    }
    View Code

    H

    https://atcoder.jp/contests/abc170/tasks/abc170_d?lang=en

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n;
        cin >> n;
    
        int m = 1000001;
    
        vector<int> a(n);
        vector<int> cnt(m);
        vector<bool> vis(m);
    
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
            cnt[a[i]] += 1;
        }
    
        for(int i = 1; i < m; ++i) {
            if(cnt[i] > 0) {
                for(int j = i + i; j < m; j += i) {
                    vis[j] = true;
                }
            }
        }
    
        long long ans = n;
    
        for(int i : a) {
            if(cnt[i] > 1 || vis[i]) {
                ans -= 1;
            }
        }
    
        cout << ans << '
    ';
    
        return 0;
    }
    View Code
  • 相关阅读:
    ABAP开发常见任务
    sap smartform 打印乱码问题
    根据T-Code查看用户出口的代码
    java 调用SAP RFC函数错误信息
    代码单行超过72个字符的一个异常
    SAP 权限层次
    标准屏幕字段描述修改
    [转]SAP一句话入门SD模块
    Python3.7,os模块
    Python3,逻辑运算符
  • 原文地址:https://www.cnblogs.com/19992147orz/p/14322556.html
Copyright © 2011-2022 走看看