• DAY1


    传送门

    A数学题统计

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define mod 1000000007
     
    long long m,n;
     
    long long sum;
     
    int main()
    {
      scanf("%lld%lld",&m,&n);
      long long int a,b;
      a=2*(m+n-2);
      b=(2*m*n-3*m-3*n+4);
      sum=((a%mod)*(b%mod))%mod;
      printf("%lld
    ",sum );
      return 0;
    }
    View Code

    B数学期望

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
     
    int n,x,a,b;
     
    int main()
    {
        scanf("%d%d%d%d",&n,&x,&a,&b);
        int aa,bb;
        aa=n*a;
        bb=n*b;
        double ans;
        ans=aa*x+bb*(100-x);
        ans=ans/100.;
        printf("%.2lf",ans);   
        return 0;
    }
    View Code

    D水题排序

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define N 100009
    using namespace std;
     
    int n;
     
    int a[N];
     
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<n;i++) scanf("%d",&a[i]);
        sort(a+1,a+n);a[n]=n+1;
        for(int i=1;i<=n;i++)
        {
            if(i!=a[i])
            {
                cout<<i;
                break;
            }
        }
        return 0;
    }
    View Code

    E数学题根号n求因子个数

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int get_num(long long n){
        int tot=1;
        for(int i=2;i*i<=n;++i){
            if(n%i==0){
                int x=0;
                while(n%i==0){
                    n/=i;
                    x++;
                }
                tot*=(x+1);
            }
        }
        if(n>1)tot*=2;
        return tot;
    }
     
    int main(){
        long long n;
        cin>>n;
        int ans=0;
        while(n!=2)
        {
            n=get_num(n);//求n的因子个数
            ans++;
        }
        cout<<ans;
        return 0;
    }
    View Code

    F图论题dfs求每个黑点对答案的贡献

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define N 100009
    #define LL long long
    using namespace std;
     
    int n;
    LL cnt,ans;
     
    int sumedge;
     
    int head[N],vis[N];
     
    char col[N];
     
    struct Edge
    {
        int x,y,nxt;
        Edge(int x=0,int y=0,int nxt=0):
        x(x),y(y),nxt(nxt){}
    }edge[N<<1];
     
    void add(int x,int y)
    {
        edge[++sumedge]=Edge(x,y,head[x]);
        head[x]=sumedge;
    }
     
    void dfs(int x)
    {
        for(int i=head[x];i;i=edge[i].nxt)
        {
            int v=edge[i].y;
            if(col[v]=='B'||vis[v]) continue;
            vis[v]=true;cnt++;
            dfs(v);
        }
    }
     
    void slove()
    {
     
        for(int k=1;k<=n;k++)
        {
            if(col[k]=='W') continue;
            int x=k;
            LL tot=0;
            memset(vis,0,sizeof(vis));
            for(int i=head[x];i;i=edge[i].nxt)
            {
                int v=edge[i].y;
                if(col[v]=='W')
                {
                    cnt=1;
                    vis[v]=true;
                    dfs(v);
                    ans=ans+tot*cnt+cnt;
                    tot=tot+cnt;
                }
            }
        }
        cout<<ans<<endl;
    }
     
    int main()
    {
        scanf("%d",&n);
        scanf("%s",col+1);
        for(int i=1;i<n;i++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            add(x,y);
            add(y,x);
        }
        slove();
        return 0;
    }
    View Code

    G字符串题妙啊妙

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define N 200009
    using namespace std;
     
    int n,k,ans;
     
    char s[N];
     
    int cnt[30];
     
    int pos[30][N];
     
    int main()
    {
       scanf("%d%d",&n,&k);
       scanf("%s",s+1);
       ans=n+1;
       for(int i=1;i<=n;i++)
       {
           int x=s[i]-'a'+1;
           cnt[x]++;
           pos[x][cnt[x]]=i;
       }
       for(int i=1;i<=26;i++)
       {
           if(cnt[i]<k) continue;
           for(int j=1;j<=cnt[i]-k+1;j++)
           {
               ans=min(ans,pos[i][j+k-1]-pos[i][j]+1);
           }
       }
        if(ans==n+1) cout<<"-1
    ";
        else cout<<ans<<endl;
        return 0;
    }
    View Code

    H二分+贪心

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define N 200009
    using namespace std;
     
    int n,k;
     
    int l,r,mid,ans;
     
    int sum[N];
     
    char s[N];
     
    bool check(int x)
    {
        for(int i=0;i<=n-x;i++)
        {
            if(x-(sum[i+x]-sum[i])<=k)return true;
            if(sum[i+x]-sum[i]<=k) return true;
        }
        return false;
    }
     
    int main()
    {
        scanf("%d%d",&n,&k);
        scanf("%s",s+1);
        for(int i=1;i<=n;i++)
        {
            sum[i]=sum[i-1]+s[i]-'0';
        }
        l=1;r=n;
        while(l<=r)
        {
            mid=(l+r)>>1;
            if(check(mid))
            {
                ans=mid;
                l=mid+1;
            }else r=mid-1;
        }
        cout<<ans<<endl;
        return 0;
    }
    View Code

    I字符串区间dp妙啊妙

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define N 300009
    #define LL long long
    using namespace std;
     
    int n,a,b,c;
     
    string s;
     
     LL dp[N];
     
    int main()
    {
        scanf("%d%d%d%d",&n,&a,&b,&c);
        cin>>s;
        for(int i=0;i<n;i++)
        {
            if(i)dp[i]=max(dp[i],dp[i-1]);
            if(i+3<n&&s.substr(i,4)=="nico") dp[i+3]=max(dp[i+3],dp[i]+a);
            if(i+5<n&&s.substr(i,6)=="niconi") dp[i+5]=max(dp[i+5],dp[i]+b);
            if(i+9<n&&s.substr(i,10)=="niconiconi")dp[i+9]=max(dp[i+9],dp[i]+c);
        }
        cout<<dp[n-1];
        return 0;
    }
    View Code
  • 相关阅读:
    【Android测试】Android截图的深水区
    【Android测试】UI自动化代码优化之路
    网页爬虫小试牛刀
    【Android测试】【第十九节】Espresso——API详解
    【iOS测试】【随笔】帧率FPS评测
    【iOS测试】【随笔】崩溃日志获取
    【后台测试】Linux下小试jmeter
    【后台测试】手把手教你jmeter压测
    【行业交流】2016 TiD质量竞争力大会——移动互联网测试到质量的转变之路
    【Android测试】【第十八节】Espresso——环境搭建
  • 原文地址:https://www.cnblogs.com/zzyh/p/12267027.html
Copyright © 2020-2023  润新知