• 2020 计蒜之道 线上决赛


    A

    不是 2 就是 3

    int main() {
        IOS; cin >> n >> m;
        int cnt = 0;
        rep (i, 1, n) cin >> a[i], cnt += (a[i] == 1);
        if (cnt >= 2) cout << 2 << '
    ';
        else cout << 3 << '
    ';
        return 0;
    }
    

    B

    水题

    int main() {
        IOS; cin >> n >> m;
        rep (i, 1, n) cin >> a[i].se >> a[i].fi;
        sort(a + 1, a + 1 + n);
        rep (i, 1, n - 1) {
            ll cur = i * a[i].fi;
            cout << a[i].se << ' ' << cur / m << ' ' << m - cur % m << '
    ';
        } cout << a[n].se;
        return 0;
    }
    

    C

    静态主席树板子题

    const int N = 1e5 + 5;
    
    struct CHT {
        struct node {
            int val, lson, rson;
            node (int Val = 0, int Ls = 0, int Rs = 0)
                : val(Val), lson(Ls), rson(Rs){}
        } tr[20 * N]; //log2(n)*n
    
        int root[N], tot;
    
        void update(int &x, int y, int l, int r, int k, int cnt) {
            tr[x = ++tot] = tr[y]; tr[x].val += cnt;
            if (l == r) return;
            int mid = l + r >> 1;
            if (k <= mid) update(tr[x].lson, tr[y].lson, l, mid, k, cnt);
            else update(tr[x].rson, tr[y].rson, mid + 1, r, k, cnt);
        }
    
        int ask(int x, int y, int l, int r, int cnt) {
            if (l == r) return l;
            int mid = l + r >> 1;
            int res = -1;
            if (tr[tr[x].lson].val - tr[tr[y].lson].val > cnt)
                umax(res, ask(tr[x].lson, tr[y].lson, l, mid, cnt));
            if (tr[tr[x].rson].val - tr[tr[y].rson].val > cnt)
                umax(res, ask(tr[x].rson, tr[y].rson, mid + 1, r, cnt));
            return res;
        }
    } bit;
    
    int n, m, _, k;
    
    int main() {
        IOS; cin >> n >> m;
        VI a(n + 1), c(n + 1);
        rep (i, 1, n) cin >> a[i], c[i] = a[i];
        sort(all(c)); c.erase(unique(all(c)), c.end());
        rep (i, 1, n) {
            a[i] = lower_bound(all(c), a[i]) - c.begin();
            bit.update(bit.root[i], bit.root[i - 1], 1, n, a[i], 1);
        }
        rep (i, 1, m) {
            int x, y, t; cin >> x >> y >> t;
            int ans = bit.ask(bit.root[y], bit.root[x - 1], 1, n, (y - x + 1) / t);
            cout << (ans == -1 ? -1 : c[ans]) << '
    ';
        }
        return 0;
    }
    

    F

    组合数学, 选1~m种板子(颜色), 最后一块板子一定放到 第m个小球的后面

    剩下的 i - 1块板子, 放到 m - 1 个缝隙之中

    ll inv[N] = {0, 1}, a[N] = {1, 1}, b[N] = {1, 1};
    
    ll C(int x, int y, int p = mod) {
        if (y == 0 || x == p) return 1;
        if (x < 0 || y < 0 || y > x) return 0;
        return a[x] * b[y] % p * b[x - y] % p;
    }
    
    void init(int n, int p = mod) {
        rep (i, 2, n) {
            inv[i] = (ll)(p - p / i) * inv[p % i] % p;
            a[i] = (ll)a[i - 1] * i % p;
            b[i] = (ll)b[i - 1] * inv[i] % p;
        }
    }
    
    int main() {
        IOS; cin >> n >> m; init(n);
        ll ans = 0;
        rep (i, 1, m) ans = (ans + (ll)C(n, i) * C(m - 1, i - 1) % mod) % mod;
        cout << ans;
        return 0;
    }
    
  • 相关阅读:
    设计模式
    三——第二部分——第二篇论文 计划建设SQL Server镜像
    非正确使用浮点数据由项目产生BUG讨论的问题
    重写ViewPager实施单一交有关切换到这个问题,并没有缓存
    1159 Palindrome(最小插入回文串)
    CSDN-markdown编者LaTex数学公式
    找工作总结
    开展:随笔记录 OSGI的jar增加了一些小问题和注意事项
    js jquery版本号 金额千分之一转换功能(非规范,高效率)
    dom4j.jar有什么作用?
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/13871826.html
Copyright © 2020-2023  润新知