2019 Multi-University Training Contest 7

SolvedPro.IDTitleRatio(Accepted / Submitted)
1001A + B = C10.52%(302/2872)
1002Bracket Sequences on Tree11.27%(16/142)
1003Cuber Occurrence6.67%(1/15)
1004Data Structure Problem23.08%(3/13)
1005Equation0.00%(0/63)
已补1006Final Exam5.06%(297/5872)
1007Getting Your Money Back12.42%(20/161)
1008Halt Hater14.77%(61/413)
1009Intersection of Prisms0.00%(0/2)
1010Just Repeat15.04%(128/851)
img1011Kejin Player21.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\n",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\n", ((pre[r - 1] - pre[l - 1]) + mod) % mod);
        }
    }
    return 0;
}

转载于:https://www.cnblogs.com/1625--H/p/11348857.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值