• 4/5邀请赛的选拔赛,闷声滚大粗


    A-HDU2710
    cdmSB
    这题题目明确告诉你有一组数据
    结果数据tm全是多组的
    卡了两个小时,最后加一个循环读入A了,= =
    cdmSB

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    const int N=200000;
    int prime[N+100],len,n,Max=0;
    int ans=1;
    bool v[N+100];
    void get_prime(){
        for (int i=2;i<N;i++){
            if (!v[i]) prime[++len]=i;
            for (int j=1;j<=len&&i*prime[j]<N;j++){
                v[i*prime[j]]=1;
                if (i%prime[j]==0) break;
            }
        }
    }
    void Do(int x){
        if (x==1){
            if (Max<1) Max=1,ans=x;
            return;
        }
        for (int i=1;i<=len&&prime[i]<=x;i++){
            if (x%prime[i]==0){
                if (prime[i]>Max) Max=prime[i],ans=x;
            }
        }
    }
    int main(){
        get_prime();
        for (;~scanf("%d",&n);){
                Max=0; ans=0;
        for (int i=1;i<=n;i++){
            int x;
            scanf("%d",&x);
            Do(x);
        }
        printf("%d
    ",ans);
        }
        return 0;
    }

    C HDU 5095
    蠢到不敢相信
    直接输出就好了

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    int T;
    int main(){
        scanf("%d",&T);
        for (;T--;){
            bool flag=0;
            int c;
            for (char x='p';x<='z';x++){
                if (x=='s'||x=='t') continue;
                scanf("%d",&c);
                if (c==0) continue;
                if (c>0&&flag){
                    if (c==1) printf("+%c",x);
                    else printf("+%d%c",c,x);
                    flag=1;
                }else{
                    if (c==1||c==-1){
                        if (c==1) printf("%c",x);
                        if (c==-1) printf("-%c",x);
                    }
                    else printf("%d%c",c,x);
                    flag=1;
                }
            }
            scanf("%d",&c);
            if (c!=0){
                if (c>0&&flag){printf("+%d",c);}
                else{printf("%d",c);}
            }
            puts("");
        }
    }

    D HDU 4287
    写的非常不优雅

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    const int N=10000;
    int T,n,m;
    int a[N];
    int num[1000000];
    int Map[256];
    int scanc(){
        char ch=getchar();
        int x=0;
        for (;ch<'a'||ch>'z';ch=getchar());
        for (;ch>='a'&&ch<='z';ch=getchar()) x=x*10+Map[ch];
        return x;
    }
    int main(){
        scanf("%d",&T);
        for (int i='a';i<='c';i++) Map[i]=2;
        for (int i='d';i<='f';i++) Map[i]=3;
        for (int i='g';i<='i';i++) Map[i]=4;
        for (int i='j';i<='l';i++) Map[i]=5;
        for (int i='m';i<='o';i++) Map[i]=6;
        for (int i='p';i<='s';i++) Map[i]=7;
        for (int i='t';i<='v';i++) Map[i]=8;
        for (int i='w';i<='z';i++) Map[i]=9;
        for (;T--;){
            scanf("%d%d",&n,&m);
            memset(num,0,sizeof(num));
            for (int i=1;i<=n;i++) scanf("%d",&a[i]),num[a[i]]=1;
            for (int i=1;i<=m;i++){
                int x=scanc();
                if (num[x]>0) num[x]++;
            }
            for (int i=1;i<=n;i++) printf("%d
    ",num[a[i]]-1);
        }
        return 0;
    }

    J HDU 1711

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    const int N=1000086;
    int a[N],b[N],f[N];
    int n,m;
    bool flag=0;
    void Find(int *T,int *P){
        int j=0;
        for (int i=0;i<n;i++){
            for (;j&&P[j]!=T[i];) j=f[j];
            if (P[j]==T[i]) j++;
            if (j==m){
                printf("%d
    ",i-m+2),flag=1;
                return;
            }
        }
    }
    void GetFail(int *P){
        f[0]=f[1]=0;
        for (int i=1;i<m;i++){
            int j=f[i];
            for (;j&&P[i]!=P[j];) j=f[j];
            f[i+1]=P[i]==P[j]?j+1:0;
        }
    }
    int main(){
        int T;
        scanf("%d",&T);
        for (;T--;){
            scanf("%d%d",&n,&m);
            flag= 0;
            memset(f,0,sizeof(f));
            for (int i=0;i<n;i++) scanf("%d",&a[i]);
            for (int i=0;i<m;i++) scanf("%d",&b[i]);
            GetFail(b);
          //  puts("!!!!");
            Find(a,b);
         //   puts("!!!!");
            if (!flag) puts("-1");
        }
        return 0;
    }

    L CodeForces 622D
    一开始打表找规律,然后。。。。找不到
    然后开始思考人生,,,,乱搞

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    const int N=100086;
    int a[N],n;
    int main(){
        for (;~scanf("%d",&n);){
            memset(a,0,sizeof(a));
            if (n%2==0){
                for (int i=1;i<=n;i+=2) printf("%d ",i);
                for (int i=n-1;i>=1;i-=2) printf("%d ",i);
                for (int i=2;i<=n;i+=2) printf("%d ",i);
                for (int i=n-2;i>=2;i-=2) printf("%d ",i);
                printf("%d
    ",n);
            }else{
                for (int i=1;i<=n;i+=2) printf("%d ",i);
                for (int i=n-2;i>=1;i-=2) printf("%d ",i);
                for (int i=2;i<=n;i+=2) printf("%d ",i);
                for (int i=n-1;i>=2;i-=2) printf("%d ",i);
                printf("%d
    ",n);
            }
        }
        return 0;
    }

    M HDU 5147
    煞笔树状数组

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <cstring>
    #include <cmath>
    using namespace std;
    typedef long long ll;
    const int N=100086;
    int C[N*4];
    int a[N],n;
    ll f[N],g[N];
    void Add(int x,int d){
        for (;x<=n;x+=x&-x) C[x]+=d;
    }
    int Query(int x){
        int re=0;
        for (;x;x-=x&-x) re+=C[x];
        return re;
    }
    int scan(){
        char ch=getchar();
        int x=0;
        for (;ch<'0'||ch>'9';ch=getchar());
        for (;ch<='9'&&ch>='0';ch=getchar()) x+=(x<<3)+x+ch-48;
        return x;
    }
    int main(){
        int T=scan();
        for (;T--;){
            n=scan();
            memset(C,0,sizeof(C));
            memset(f,0,sizeof(f));
            memset(g,0,sizeof(g));
            for (int i=1;i<=n;i++){
                a[i]=scan();
                f[i]=Query(a[i]-1);
                Add(a[i],1);
            }
            memset(C,0,sizeof(C));
            for (int i=n;i;i--){
                g[i]=g[i+1]+Query(n)-Query(a[i]);
                Add(a[i],1);
            }
            ll ans=0;
            //for (int i=1;i<=n;i++) printf("f[%d]=%I64d  g[%d]=%I64d
    ",i,f[i],i,g[i]);
            for (int i=1;i<n;i++) ans+=f[i]*g[i+1];
            cout<<ans<<endl;
        }
        return 0;
    }

    主要输出在一个痴迷艹舰的孩子身上
    下次前期我上(虽然可能会增加罚时)
    这里写图片描述
    这里写图片描述
    一开始被A坑的有点惨,艹tm的,cdmSB
    最后几分钟进入乱交模式= =。。。

  • 相关阅读:
    (HDU)1097 --A hard puzzle(难题)
    (HDU)1096 --A+B for Input-Output Practice (VIII)(输入输出练习(VIII))
    PAT B1008——数组元素循环右移
    test
    vue iconfont矢量图
    css3简单旋转
    vue 路由的安装及使用
    vue 父组件与子组件之间的相互调用
    vue 脚手架安装
    PHP 加密方式
  • 原文地址:https://www.cnblogs.com/cww97/p/7534004.html
Copyright © 2020-2023  润新知