• Contest 4


      A:cf原题。当然是不是也没什么关系。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int read()
    {
        int x=0,f=1;char c=getchar();
        while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
        while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        return x*f;
    }
    #define N 1000010
    int n,a[N];
    int main()
    {
        freopen("sequence.in","r",stdin);
        freopen("sequence.out","w",stdout);
        n=read();
        for (int i=1;i<=n;i++) a[i]=read();
        sort(a+1,a+n+1);
        cout<<a[n]-a[1]-n+1;
        return 0;
    }
    View Code

      B:非常裸的矩乘。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int read()
    {
        int x=0,f=1;char c=getchar();
        while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
        while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        return x*f;
    }
    #define P 1000000007
    #define N 9
    int T,n;
    struct matrix
    {
        int n,a[N][N];
        matrix operator *(matrix b) const
        {
            matrix c;c.n=n;memset(c.a,0,sizeof(c.a));
            for (int i=0;i<n;i++)
                for (int j=0;j<N;j++)
                    for (int k=0;k<N;k++)
                    c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j]%P)%P;
            return c;
        }
    }f,a,b;
    int trans(int x,int y){return x*3+y;}
    int main()
    {
        freopen("food.in","r",stdin);
        freopen("food.out","w",stdout);
        T=read();
        a.n=N;f.n=1;
        for (int i=0;i<3;i++)
            for (int j=0;j<3;j++)
                for (int k=0;k<3;k++)
                if (!(i==j&&j==k)&&!(j==0&&i+k==3)&&!((j==1||j==2)&&(i==0&&k==0))) a.a[trans(i,j)][trans(j,k)]=1;
        b=a;
        while (T--)
        {
            n=read()-2;
            if (n<0) {printf("3
    ");continue;}
            a=b;
            for (int i=0;i<9;i++) f.a[0][i]=1;
            for (;n;n>>=1,a=a*a) if (n&1) f=f*a;
            int ans=0;
            for (int i=0;i<9;i++) ans=(ans+f.a[0][i])%P;
            printf("%d
    ",ans);
        }
        return 0;
    }
    View Code

      C:非常显然的堆。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<queue>
    #include<vector>
    using namespace std;
    int read()
    {
        int x=0,f=1;char c=getchar();
        while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
        while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        return x*f;
    }
    #define N 100010
    #define ll long long
    int n,a[N],b[N],cnt;
    ll delta;
    priority_queue<ll,vector<ll>,greater<ll> >q;
    int main()
    {
        freopen("snow.in","r",stdin);
        freopen("snow.out","w",stdout);
        n=read();
        for (int i=1;i<=n;i++) a[i]=read();
        for (int i=1;i<=n;i++) b[i]=read();
        for (int i=1;i<=n;i++)
        {
            q.push(a[i]+delta);cnt++;
            ll ans=0;
            while (!q.empty()&&q.top()<=delta+b[i]) ans+=q.top()-delta,q.pop(),cnt--;
            delta+=b[i];
            printf("%I64d ",ans+1ll*cnt*b[i]);
        }
        return 0;
    }
    View Code

       result:300 rank1

  • 相关阅读:
    Struts2+Uploadify文件上传使用详解
    jquery常用代码集锦
    springmvc+hibernate入门-揭开神秘的面纱
    Jqgrid入门-Jqgrid格式化数据(九)
    Jqgrid入门-Jqgrid分组的实现(八)
    利用jekyll架设个人博客
    Centos7安装jekyll
    服务器改造个人工作站经验总结
    王爽汇编环境搭建
    由于没有公钥,下列签名无法进行验证
  • 原文地址:https://www.cnblogs.com/Gloid/p/9739680.html
Copyright © 2020-2023  润新知