zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 103 (Rated for Div. 2)

    Educational Codeforces Round 103 (Rated for Div. 2)

    A - K-divisible Sum

    int main() {
        IOS;
        for (cin >> _; _; --_) {
            ll n, k; cin >> n >> k; k = ((n - 1) / k + 1) * k;
            cout << (k - 1) / n + 1 << '
    ';
        }
        return 0;
    }
    

    B - Inflation

    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n >> k; VL a(n + 1), b(n + 1);
            rep (i, 1, n) cin >> a[i], b[i] = a[i] + b[i - 1];
            ll ans = 0, cur = 0;
            per (i, n, 2) {
                if (a[i] * 100 <= k * b[i - 1]) continue;
                ll res = (a[i] * 100 - k * b[i - 1] - 1) / k + 1;
                umax(ans, res);
            }
            cout << ans << '
    ';
        }
        return 0;
    }
    

    C - Longest Simple Cycle

    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n; VL c(n + 1), a(n + 1), b(n + 1);
            rep (i, 1, n) cin >> c[i], --c[i];
            rep (i, 1, n) cin >> a[i];
            rep (i, 1, n) cin >> b[i];
            ll ans = 0, cur = abs(a[2] - b[2]) << 1;
            for (int i = 2; i <= n; ++i) {
                if (a[i] == b[i]) umax(ans, cur = 2 + c[i]);
                else umax(ans, cur = max(2 - abs(a[i] - b[i]) + c[i] + cur, 2 + abs(a[i] - b[i]) + c[i]));
            }
            cout << ans << '
    ';
        }
        return 0;
    }
    

    D - Journey

    char s[N];
    int f[N], ans[N];
     
    int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
     
    void unit(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return; f[y] = x;
    }
     
    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n; cin >> s + 1;
            rep (i, 0, n) f[i] = i, ans[i] = 0;
            for (int i = 0, j = 0; i <= n;) {
                ++ans[j];
                if (s[i] == 'L') ++ans[j];
                if (i < n && s[i + 1] == 'L') { j = ++i; continue; }
                if (i == n) break;
                if (i + 1 < n && s[i + 2] == 'R') { ++ans[j]; j = ++i; }
                else if (i + 1 < n) unit(j, i + 2), ans[i + 1] = 1, i += 2;
                else ++ans[j], ans[i + 1] = 1, i += 2;
            }
            rep (i, 0, n) cout << ans[find(i)] << ' '; cout << '
    ';
        }
        return 0;
    }
    

    E -Pattern Matching

    找到能匹配的, 拓扑就行, 没调出来

  • 相关阅读:
    获取Oracle、SqlServer、Access中表名、字段和主键(转)
    Oracle事务控制总结
    Oracle数据类型
    Oracle中的数据字典技术及常用数据字典总结
    asp.net中的<%%>形式的详细用法总结
    一道sql面试题的解答
    求ax(2)+bx+c=0的解
    求发票的下一个号码
    软件设计师2008年12月下午试题4(C语言 动态规划)
    软件设计师1991下午试题1(流程图解析)
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/14347790.html
Copyright © 2011-2022 走看看