• CONTEST45 呵呵呵呵呵


    题目质量差评!为什么不给数据范围!

    A.乘积最大3

    题目:http://dev.luogu.org/problem/show?pid=2172

    题解:sb题,均值定理。

    代码:

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<iostream>
     7 #include<vector>
     8 #include<map>
     9 #include<set>
    10 #include<queue>
    11 #include<string>
    12 #define inf 1000000000
    13 #define maxn 10000000
    14 #define maxm 500+100
    15 #define eps 1e-10
    16 #define ll long long
    17 #define pa pair<int,int>
    18 #define for0(i,n) for(int i=0;i<=(n);i++)
    19 #define for1(i,n) for(int i=1;i<=(n);i++)
    20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    22 #define mod 1000000007
    23 using namespace std;
    24 inline ll read()
    25 {
    26     ll x=0,f=1;char ch=getchar();
    27     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    28     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    29     return x*f;
    30 }
    31 ll n,m,tmp,a[maxn];
    32 int main()
    33 {
    34     freopen("input.txt","r",stdin);
    35     freopen("output.txt","w",stdout);
    36     n=read();m=read();
    37     for1(i,m)a[i]=n/m;
    38     tmp=n-(n/m)*m;
    39     for3(i,m,m-tmp+1)a[i]++;
    40     for1(i,m-1)printf("%lld ",a[i]);
    41     printf("%lld
    ",a[m]);
    42     return 0;
    43 }
    View Code

    B.刮油漆

    题目:http://dev.luogu.org/problem/show?pid=U155

    题解:先差分算出每个点的高度,然后单调栈搞掉。

            不知道哪写残了一直WA,没AK真不爽。。。

    代码:

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<iostream>
     7 #include<vector>
     8 #include<map>
     9 #include<set>
    10 #include<queue>
    11 #include<string>
    12 #define inf 1000000000
    13 #define maxn 1000000+1000
    14 #define maxm 500+100
    15 #define eps 1e-10
    16 #define ll long long
    17 #define pa pair<int,int>
    18 #define for0(i,n) for(int i=0;i<=(n);i++)
    19 #define for1(i,n) for(int i=1;i<=(n);i++)
    20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    22 #define mod 1000000007
    23 using namespace std;
    24 inline int read()
    25 {
    26     int x=0,f=1;char ch=getchar();
    27     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    28     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    29     return x*f;
    30 }
    31 int n,ans,mx,top,a[maxn],b[maxn],sta[maxn];
    32 int main()
    33 {
    34     freopen("input.txt","r",stdin);
    35     freopen("output.txt","w",stdout);
    36     n=read();
    37     for1(i,n)
    38      {
    39       int x=read(),y=read();
    40       a[x]++,a[y+1]--;
    41       if(y+1>mx)mx=y+1;
    42      }
    43     for1(i,mx)b[i]=b[i-1]+a[i];
    44     ans=mx;
    45     sta[top=1]=0;
    46     for1(i,mx)
    47     {
    48         while(top>1&&sta[top]>b[i])top--;
    49         if(sta[top]==b[i])ans--;else sta[++top]=b[i];
    50     }
    51     printf("%d
    ",ans);
    52     return 0;
    53 }
    View Code

    C.选学霸

    题目:http://dev.luogu.org/problem/show?pid=2170

    题解:并查集完了之后背包,怎么昨天一天做了两道这种题?

    代码:

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<iostream>
     7 #include<vector>
     8 #include<map>
     9 #include<set>
    10 #include<queue>
    11 #include<string>
    12 #define inf 1000000000
    13 #define maxn 1000000+1000
    14 #define maxm 500+100
    15 #define eps 1e-10
    16 #define ll long long
    17 #define pa pair<int,int>
    18 #define for0(i,n) for(int i=0;i<=(n);i++)
    19 #define for1(i,n) for(int i=1;i<=(n);i++)
    20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    22 #define mod 1000000007
    23 using namespace std;
    24 inline int read()
    25 {
    26     int x=0,f=1;char ch=getchar();
    27     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    28     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    29     return x*f;
    30 }
    31 int n,m,k,ans,tot,sum,fa[maxn],a[maxn],s[maxn];
    32 bool f[maxn];
    33 inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
    34 int main()
    35 {
    36     freopen("input.txt","r",stdin);
    37     freopen("output.txt","w",stdout);
    38     n=read();k=read();m=read();
    39     for1(i,n)fa[i]=i;
    40     for1(i,m)
    41     {
    42         int x=find(read()),y=find(read());
    43         if(x!=y)fa[x]=y;
    44     }
    45     for1(i,n)s[find(i)]++;
    46     for1(i,n)if(s[i])a[++tot]=s[i];
    47     f[0]=1;
    48     for1(i,tot)
    49     {
    50      for3(j,sum,0)
    51       if(f[j])f[j+a[i]]=1; 
    52      sum+=a[i];
    53     } 
    54     for3(i,k,1)if(f[i]){ans=i;break;}
    55     for2(i,k,n)if(f[i]){if(abs(i-k)<k-ans)ans=i;break;}
    56     printf("%d
    ",ans);
    57     return 0;
    58 }
    View Code

    这场比赛没有好好做,因为看起来都是些sb题。。。

  • 相关阅读:
    HSF的原理分析
    python--cryptography加密
    PyQt5--QTDesigner--UI资源
    PyQt5--QTDesigner--UI样式表
    python--struct
    python--ffmpy3与ffmpeg
    python--you-get:视频下载
    python--base64--简单的加密和解密
    python--StringIO-在内存中读写str
    电脑技巧
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/4003996.html
Copyright © 2020-2023  润新知