• Codeforces Round #655 (Div. 2)


    unrated 呜呜呜

    A

    直接全输出1完事

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=a;i<=(b);++i)
    #define per(i,a,b) for(int i=a;i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
     
    int main() {
        ios::sync_with_stdio(0); cin.tie(0);
        for (cin >> _; _; --_) {
            cin >> n;
            rep (i, 1, n) cout << 1 << ' ';
             cout << '
    ';
        }
        return 0;
    }
    

    B

    水水水, 数论氵题

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=a;i<=(b);++i)
    #define per(i,a,b) for(int i=a;i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
     
    int main() {
        ios::sync_with_stdio(0); cin.tie(0);
        for (cin >> _; _; --_) {
            cin >> n;
            int ans = n - 1, w = 1;
            for (int i = 2; (ll)i * i <= n; ++i)
                if (n % i == 0) {
                    int c = (n / i + 1) >> 1;
                    if (ans > (ll)c * i) w = i, ans = c * i;
                    c = (n / (n / i) + 1) >> 1;
                    if (ans > (ll)c * i) w = n / i, ans = c * i;
                }
     
            cout << w << ' '  << n - w << '
    ';
        }
        return 0;
    }
    

    C

    条件判断, 看都题意就不难

    直接拍好是 0

    中间有一段 不和首尾相连的 一段啊a[i] == i, 2

    其他的都是1

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=a;i<=(b);++i)
    #define per(i,a,b) for(int i=a;i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 2e5 + 5;
     
    int n, m, _, k;
    int a[N];
     
    int main() {
        ios::sync_with_stdio(0); cin.tie(0);
        for (cin >> _; _; --_) {
            cin >> n;
            bool flag1 = 1, flag2 = 0, flag3 = 0;
            rep (i, 1, n) {
                cin >> a[i];
                if (flag1 == 1 && a[i] != i) flag1 = 0;
                else if (flag1 == 0 && a[i] == i && flag3 == 0) flag2 = 1, flag3 = 1;
                else if (flag2 == 1 && a[i] != i) flag2 = 0;
            }
     
            if (flag1 == 1) cout << 0 << '
    ';
            else if (flag1 == 0 && flag3 == 0) cout << 1 << '
    ';
            else if (flag2) cout << 1 << '
    ';
            else cout << 2 << '
    ';
        }
        return 0;
    }
    

    D

    一开始写了个假算法, 小根堆写的, wa3

    其实会发现, 对于每个数, 其相邻的两个数必定会合在一起, 只不过是合并顺序不同

    导致每个数 加的次数 不同, 直接 O(n) 延长 找就行

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=a;i<=(b);++i)
    #define per(i,a,b) for(int i=a;i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 2e5 + 5;
     
    int n, m, _, k;
    bool v[N];
    int lf[N], rg[N];
    ll a[N << 1], sum[N << 1];
     
    int main() {
        ios::sync_with_stdio(0); cin.tie(0);
        cin >> n;
        rep (i, 1, n) cin >> a[i], a[i + n] = a[i];
    
        sum[1] = a[1];
        rep (i, 2, n * 2) sum[i] = sum[i - 2] + a[i];
    
        ll ans = 0; 
        rep (i, n + 1, n * 2) ans = max(ans, sum[i] - sum[i - n - 1]);
    
        cout << ans;
    
        return 0;
    }
    

    E

    应该是dp, 没想出来

  • 相关阅读:
    后缀数组模板
    UVALive
    蓝桥杯 拿糖果
    蓝桥杯 矩阵乘法(区间DP)
    51nod 矩阵乘法
    13.boost有向无向图邻接表表示
    12.boost有向图无向图(矩阵法)
    11.使用boostregex遭遇无法打开libboost_regex-vc120-mt-sgd-1_62.lib的问题
    10.ref regex unordered_set smartpoint
    9.variant move function change_cast
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/13287844.html
Copyright © 2020-2023  润新知