zoukankan      html  css  js  c++  java
  • HZNU Training 10 for Zhejiang Provincial Competition 2020

    A - A Count Task

     HDU - 6480 

    找出所有的区间只含一种字母。

    注意long long

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define pb push_back
    const int N=1e6+5;
    int main(){
        int t;
        scanf("%d",&t);
        while(t--){
            string s;
            cin>>s;
            ll len=s.size();
            ll  cur=0,ans=0,pos=0;
            for(ll i=0;i<len;i++){
                if(s[i]==s[pos]){cur++;}
                else if(s[i]!=s[pos]){pos=i;ans+=cur*(cur+1)/2;cur=1;}
            } 
            ans+=cur*(cur+1)/2;
            printf("%lld
    ",ans);       
        }
        // system("pause");
        return 0;   
    }
    View Code

    C - A Path Plan

     HDU - 6482 

    组合计数;

    考虑所有情况,Cc(x1+y1,x1)*Cc(x2+y2,x2);

    剔除相遇情况:Cc(x1+y2,x1)*Cc(x2+y1,x2);

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const ll mod=1e9+7;
    const int N=2e5+6;
    // const ll mod=998244353;
    ll fac[N],inv[N];
    ll pow_mod(ll a,ll n)
    {
        ll ret =1;
        while(n)
        {
            if(n&1) ret=ret*a%mod;
              a=a*a%mod;
              n>>=1;
        }
        return ret;
    }
    void init()
    {
        fac[0]=1;
        for(int i=1;i<N;i++)
        {
            fac[i]=fac[i-1]*i%mod;
        }
    }
    ll Cc(ll x, ll y)
    {
        return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
    }
    int main(){
        init();
        int t;
        scanf("%d",&t);
        while(t--){
            int x1,x2,y1,y2;
            scanf("%d %d %d %d",&x1,&x2,&y1,&y2);
            ll a=(Cc(x1+y1,x1)*Cc(x2+y2,x2))%mod;
            ll b=(Cc(x1+y2,x1)*Cc(x2+y1,x2))%mod;
            ll ans=(a-b+mod)%mod;
            printf("%lld
    ",ans);
        }
        // system("pause");
        return 0;
    }
    View Code

    E - A Hard Allocation

     HDU - 6484 

    签到,

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        int t;
        scanf("%d",&t);
        while(t--){
            ll n,m;
            scanf("%lld %lld",&n,&m);
            // ll
            if(n%m)puts("1");
            else puts("0");
        }
      
       // system("pause");
        return 0;
    }
    View Code
    想的太多,做的太少;
  • 相关阅读:
    性能分析与调优思想
    python散列实现映射抽象数据类型
    python接口模拟100个用户登录
    大O记法
    linux查看操作系统版本信息
    Python招聘信息
    flask-login模块官网内容整理
    python|base|环境搭建
    echarts|map
    mysql|unsigned 与 signed 类型
  • 原文地址:https://www.cnblogs.com/littlerita/p/12545138.html
Copyright © 2011-2022 走看看