zoukankan      html  css  js  c++  java
  • 2019 Multi-University Training Contest 7

    Solved Pro.ID Title Ratio(Accepted / Submitted)
    1001 A + B = C 10.52%(302/2872)
    1002 Bracket Sequences on Tree 11.27%(16/142)
    1003 Cuber Occurrence 6.67%(1/15)
    1004 Data Structure Problem 23.08%(3/13)
    1005 Equation 0.00%(0/63)
    已补 1006 Final Exam 5.06%(297/5872)
    1007 Getting Your Money Back 12.42%(20/161)
    1008 Halt Hater 14.77%(61/413)
    1009 Intersection of Prisms 0.00%(0/2)
    1010 Just Repeat 15.04%(128/851)
    img 1011 Kejin Player 21.20%(544/2566)

    1006

    这题想了很久,但是题解只有一句话

    换位思考, 考虑如果我们是出题人会怎么让学生做不出 k 题, 即最坏情况.显然, 我们会挑出学 生复习得最少的 (n - k + 1) 道题, 让每道题的难度都等于他复习的时间.(田忌赛马的策略)

    因此, 回到学生视角, 我们要让自己复习的最少的 (n - k + 1) 题复习时间总和 > m, 构造方式显然. 那么, QQ 小方还来得及复习吗?

    既然要让复习最少的(n-k+1)题复习时间总和大于m,首先要保证复习时间最少的题目有多少复习时间。即(m/(n-k+1))。所以(m/(n-k+1) + 1)就是其他复习时间不是最少的题目的复习时间。

    所以答案为((m/(n-k+1)+1)*(k-1) + m+1)

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int t;
    ll n,m,k;
    
    int main(){
        cin>>t;
        while(t--){
            scanf("%lld%lld%lld",&n,&m,&k);
            ll d = k-1;
            ll now = n-d;//n-k+1
            ll ans = m + 1;
            ll maxn = m / now + 1;
            ans = ans + maxn * d;
            printf("%lld
    ",ans);
        }
        return 0;
    }
    

    1011

    (E_i) 为第(i) 关到(i+1) 的期望花费,那么

    [E_i = p * a_i + (1-p)*(sum_{{j=x_i}}^{{i-1}}E_j+E_i+a_i) ]

    [E_i = {(sum_{{j=x_i}}^{{i-1}}E_j+a_i)*(1-p)over p} + a_i ]

    最后(l)(r) 的期望花费即(sum_{j=l}^{r-1}E_j)

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const ll mod = 1e9 + 7;
    inline int read()
    {
        char c=getchar();int x=0,f=1;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        return x*f;
    }
    ll gcd(ll x, ll y) {
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    ll pow_mod(ll x, ll y) {
        ll res = 1;
        while(y) {
            if(y & 1) res = res * x % mod;
            x = x * x % mod;
            y >>= 1;
        }
        return res;
    }
    int r[500005];
    int s[500005];
    int x[500005];
    int a[500005];
    ll pre[500005];
    
    int main() {
        int T;
        scanf("%d", &T);
        while(T--) {
            int n, m;
            n = read(); m = read();
            for(int i = 1; i <= n; i++) {
                r[i] = read(), s[i] = read(), x[i] = read(), a[i] = read();
            }
            pre[0] = 0LL;
            for(int i = 1; i <= n; i++) {
                ll tmp = 1LL * (s[i] - r[i]) * pow_mod(1LL * r[i], mod - 2LL) % mod;
                tmp = ((pre[i - 1] - pre[x[i] - 1] + a[i]) * tmp % mod + a[i]) % mod;
                pre[i] = (pre[i - 1] + tmp) % mod;
                pre[i] = (pre[i] + mod) % mod;
            }
            while(m--) {
                int l, r;
                l = read();
                r = read();
                printf("%lld
    ", ((pre[r - 1] - pre[l - 1]) + mod) % mod);
            }
        }
        return 0;
    }
    
  • 相关阅读:
    BigDecimal中的8中舍入模式详解
    使用二倍均值法完成红包算法
    使用Calendar类和它的子类GregorianCalendar类实现构建动态日历
    『MelodyHub』书写是对思维的缓存
    本站已接入音乐播放器API
    【LeetCode】35. 搜索插入位置
    配置NodeJs环境变量
    利用GitHub博客连接多仓库
    hexo 大型车祸现场
    随机图片API
  • 原文地址:https://www.cnblogs.com/1625--H/p/11348857.html
Copyright © 2011-2022 走看看