• 2019 Multi-University Training Contest 7


    Final Exam

    题意:一共有n道题,需要做对k道题,每个题有一个分数,要想做对这道题,需要准备的时间是这道题的分数加1,给出n道题的总分数m,问你做对k道题花费的最少时间,还有就是,你学了哪儿道题,出题人就会想办法阻止你,比如你学一道题1分钟,他会把这道题目的分数提高到>=1分,但是满足最后的总分数是m。

     

    题解:他阻止我分数最小的n-k+1个,然后把剩下的k-1个变成前面n-k个里面“最大的数(相等或者加一)”(正好整除,就是前面的数加1,不整除就是前面的向下取整加一,然后把多于的平均分到前面的上面就好),然后前面的数再加1(正好整除随便分到前面任意一个数,不整除可以加到前面的没有平均分到的那个位置),这样保证前面n-k+1个的总和>m,这样总时间会更小.

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    ll n,m,k,k2,k1;
    int main()
    {
        int _;
        scanf("%d",&_);
        while (_--)
        {
            scanf("%lld%lld%lld",&n,&m,&k);
            printf("%lld
    ",m+1+(m/(n-k+1)+1)*(k-1));
        }
    }

    Kejin Player

    E[i]+a[i]=E[i+1]*p[i]+E[x[i]]*(1-p[i])

    #include <bits/stdc++.h>
     
    using namespace std;
    const int mod=1e9+7;
    typedef long long ll;
    const int maxn=500010;
    ll n,q,r[maxn],s[maxn],x[maxn],a[maxn],p[maxn],f[maxn];
     
    ll pow_mod(ll a,ll b)
    {
        ll res=1;
        while (b)
        {
            if (b&1)
            {
                res=res*a%mod;
            }
            a=a*a%mod;
            b>>=1;
        }
        return res;
    }
     
    ll inv(ll x)
    {
        return pow_mod(x,mod-2);
    }
    inline ll read()
    {
        ll res=0,f=1;
        char ch=getchar();
        while (!isdigit(ch))
        {
            if (ch=='-')
            {
                f=-f;
            }
            ch=getchar();
        }
        while (isdigit(ch))
        {
            res=(res<<3)+(res<<1)+ch-'0';
            ch=getchar();
        }
        return f*res;
    }
    int main()
    {
        int _;
        scanf("%d",&_);
        while (_--)
        {
            scanf("%lld%lld",&n,&q);
            for (int i=1; i<=n; i++)
            {
                r[i]=read();s[i]=read();x[i]=read();a[i]=read();
                p[i]=r[i]*inv(s[i])%mod;
            }
            for (int i=2; i<=n+1; i++)
            {
                f[i]=(f[i-1]+a[i-1]%mod+f[x[i-1]]*(mod-(1-p[i-1]+mod))%mod)*inv(p[i-1])%mod;
            }
     
            while (q--)
            {
                ll l,r;
                scanf("%lld%lld",&l,&r);
                printf("%lld
    ",(f[r]-f[l]+mod)%mod);
            }
        }
    }

    A + B = C

     

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    const int maxn = 5e5 + 10,limit = 3e5 + 6;
    int dis[maxn];
    
    int solve(int c[],int lenc,int a[],int lena,int b[],int lenb)
    {
        for (int i=0; i<limit; i++)
        {
            if (c[i]!=a[i])
            {
                if (c[i]<a[i])
                {
                    return -1;
                }
                break;
            }
        }
        for (int i=0; i<limit; i++)
        {
            dis[i]=c[i]-a[i];
        }
        for (int i=limit-1; i; i--)
        {
            if (dis[i]<0)
            {
                dis[i-1]--;
                dis[i]+=10;
            }
        }
        int cur=0;
        while (dis[cur]==0&&cur<limit)
        {
            cur++;
        }
        if (cur==limit)
        {
            return -1;
        }
        for (int i=0; i<lenb; i++)
        {
            if (dis[cur+i]!=b[i])
            {
                return -1;
            }
        }
        for (int i=lenb; i<limit; i++)
        {
            if (dis[i+cur])
            {
                return -1;
            }
        }
        return limit-cur-lenb;
    }
    int a[maxn], b[maxn], c[maxn];
    char s[maxn];
    
    int main()
    {
        int lena,lenb,lenc,_;
        scanf("%d",&_);
        while (_--)
        {
            memset(a,0,sizeof(a));
            memset(b,0,sizeof(b));
            memset(c,0,sizeof(c));
            scanf("%s",s);
            for (int i=0; s[i]; i++,lena=i)
            {
                a[i+1]=s[i]-'0';
            }
            scanf("%s",s);
            for (int i=0; s[i]; i++,lenb=i)
            {
                b[i+1]=s[i]-'0';
            }
            scanf("%s",s);
            for (int i=0; s[i]; i++,lenc=i)
            {
                c[i+1]=s[i]-'0';
            }
            int res;
            if ((res=solve(c+1,lenc,a+1,lena,b+1,lenb))!=-1)
            {
                printf("%d %d %d
    ",limit-lena,res,limit-lenc);
                continue;
            }
            if ((res=solve(c+1,lenc,a,lena+1,b+1,lenb))!=-1)
            {
                printf("%d %d %d
    ",limit-lena-1,res,limit-lenc);
                continue;
            }
            if ((res=solve(c+1,lenc,b+1,lenb,a+1,lena))!=-1)
            {
                printf("%d %d %d
    ",res,limit-lenb,limit-lenc);
                continue;
            }
            if ((res=solve(c+1,lenc,b,lenb+1,a+1,lena))!=-1)
            {
                printf("%d %d %d
    ",res,limit-lenb-1,limit-lenc);
                continue;
            }
            printf("-1
    ");
        }
        return 0;
    }

    Just Repeat

     

     

    #pragma GCC optimize(2)
    #include <bits/stdc++.h>
     
    using namespace std;
     
    unsigned long long k1, k2, mod;
    int n,m;
    const int maxn=1e5+5;
    int a[maxn],b[maxn],p,cnt,suma,sumb;
     
    unsigned long long rng()
    {
        unsigned long long k3 = k1, k4 = k2;
        k1 = k4;
        k3 ^= k3 << 23;
        k2 = k3 ^ k4 ^ (k3 >> 17) ^ (k4 >> 26);
        return k2 + k4;
    }
    struct node
    {
        int num,a,b;
        bool operator<(const node &b)const
        {
            return num>b.num;
        }
    } c[maxn];
     
    inline int read()
    {
        int res=0,f=1;
        char ch=getchar();
        while (!isdigit(ch))
        {
            if (ch=='-')
            {
                f=-f;
            }
            ch=getchar();
        }
        while (isdigit(ch))
        {
            res=(res<<3)+(res<<1)+ch-'0';
            ch=getchar();
        }
        return f*res;
    }
     
    int main()
    {
        int _;
        scanf("%d",&_);
        while (_--)
        {
            unordered_map <int,int> m1,m2;
            suma=sumb=cnt=0;
            scanf("%d%d%d",&n,&m,&p);
            if (p==1)
            {
                for (register int i=0; i<n; ++i)
                {
                    a[i]=read();
                }
                for (register int i=0; i<m; ++i)
                {
                    b[i]=read();
                }
            }
            else
            {
                scanf("%llu%llu%llu",&k1,&k2,&mod);
                for (int i = 0; i < n; ++i)
                    a[i] = rng() % mod;
                scanf("%llu%llu%llu",&k1,&k2,&mod);
                for (int i = 0; i < m; ++i)
                    b[i] = rng() % mod;
            }
            for (int i=0; i<n; i++)
            {
                m1[a[i]]++;
            }
            for (int i=0; i<m; i++)
            {
                m2[b[i]]++;
            }
            for (register int i=0; i<m; ++i)
            {
                if (m1[b[i]]>0)
                {
                    ++cnt;
                    c[cnt].num=m1[b[i]]+m2[b[i]];
                    c[cnt].a=m1[b[i]];
                    c[cnt].b=m2[b[i]];
                    m1[b[i]]=-1;
                }
                else if (m1[b[i]]!=-1&&m2[b[i]]!=-1)
                {
                    sumb+=m2[b[i]];
                    m2[b[i]]=-1;
                }
            }
             
            for (register int i=0; i<n; i++)
            {
                if (m2[a[i]]==0)
                {
                    suma+=m1[a[i]];
                    m2[a[i]]=-1;
                }
            }
            sort(c+1,c+cnt+1);
            for (register int i=1; i<=cnt; ++i)
            {
                if (i&1)
                {
                    suma+=c[i].a;
                }
                else
                {
                    sumb+=c[i].b;
                }
            }
     
            if (suma>sumb)
            {
                printf("Cuber QQ
    ");
            }
            else
            {
                printf("Quber CC
    ");
            }
        }
        return 0;
    }
     

    Getting Your Money Back

    Halt Hater

     
  • 相关阅读:
    PyQt5对话框
    PyQt5基础控件
    PyQt5主界面
    PyQt5入门
    ioctl太多虚拟内存不够用
    code principles
    Error: watch ENOSPC
    intelJ
    cas
    C的函数指针的作用,以及其赋值是弱类型的
  • 原文地址:https://www.cnblogs.com/Accpted/p/11341625.html
Copyright © 2020-2023  润新知