zoukankan      html  css  js  c++  java
  • Codeforces Round #639 (Div. 2)ABC

    Mike收了10W $ , 结果把CF负优化了.....

    A . Puzzle Pieces

    签到签到,一眼看出一行/一列/2*2才可能

    /*********************
    *@Author:   CKang    *
    *@Language: C++11    *
    *********************/
    #include<bits/stdc++.h>
    #pragma comment(linker, "/STACK:102400000,102400000")
    //#define DEBUG
    #define RI register int
    #define endl "
    "
    
    using namespace std;
    
    typedef long long ll;
    //typedef __int128 lll;
    //const int N=100000+10;
    const int M=100000+10;
    const int MOD=1e9+7;
    const double PI = acos(-1.0);
    const double EXP = 1E-9;
    const int INF = 0x3fffffff;
    const ll LINF = 0x3fffffffffffffff;
    
    inline ll read(){
        long long x=0,f=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){
            if(ch=='-')
                f=-1;
            ch=getchar();
        }
        while(ch>='0'&&ch<='9'){
            x=(x<<1)+(x<<3)+(ch^48);
            ch=getchar();
        }
        return x*f;
    }
    
    void solve(){
        ll n=read(),m=read();
        if(n==1||m==1)
            puts("YES");
        else if(m==2&&n==2)
            puts("YES");
        else
            puts("NO");
        return ;
    }
    
    int main()
    {
    #ifdef DEBUG
        freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout)
    #endif
        //cout.tie(0);
        for(ll t=read();t;t--)
            solve();
    #ifdef DEBUG
        printf("Time cost : %lf s
    ",(double)clock()/CLOCKS_PER_SEC);
    #endif
        //cout << "Fuck You !" << endl;
        return 0;
    }
    

    B.Card Constructions

    稍微观察一下发现规律 nums[i]= i*(3*i+1)/2; // i*i+i+(i*i-i)/2; ,然后就是快乐的打表暴力了(lower_bound不需要,因为i最多到2W5K多)

    /*********************
    *@Author:   CKang    *
    *@Language: C++11    *
    *********************/
    #include<bits/stdc++.h>
    #pragma comment(linker, "/STACK:102400000,102400000")
    //#define DEBUG
    #define RI register int
    #define endl "
    "
    
    using namespace std;
    
    typedef long long ll;
    //typedef __int128 lll;
    //const int N=100000+10;
    const int M=100000+10;
    const int MOD=1e9+7;
    const double PI = acos(-1.0);
    const double EXP = 1E-9;
    const int INF = 0x3fffffff;
    const ll LINF = 0x3fffffffffffffff;
    
    inline ll read(){
        long long x=0,f=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){
            if(ch=='-')
                f=-1;
            ch=getchar();
        }
        while(ch>='0'&&ch<='9'){
            x=(x<<1)+(x<<3)+(ch^48);
            ch=getchar();
        }
        return x*f;
    }
    
    ll pos=0,nums[100005]={0};
    
    void init(){
        for(ll i=1;nums[i-1]<=1000000000;i++,pos++){
            nums[i]= i*(3*i+1)/2; // i*i+i+(i*i-i)/2;
            //cout<<nums[i]<<endl;
        }
        pos--;
        //cout<<pos<<endl;
        return;
    }
    
    void solve(){
        ll n=read(),ans=0;
        for(int i=pos;i>0;i--){
            if(n>=nums[i]){
                n-=nums[i];
                ans++;
                i++;
            }
        }
        cout<<ans<<endl;
        return ;
    }
    
    int main()
    {
    #ifdef DEBUG
        freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout)
    #endif
        //cout.tie(0);
        init();
        for(ll t=read();t;t--)
            solve();
    #ifdef DEBUG
        printf("Time cost : %lf s
    ",(double)clock()/CLOCKS_PER_SEC);
    #endif
        //cout << "Fuck You !" << endl;
        return 0;
    }
    

    C.Hilbert's Hotel

    这是一个神奇的题目,因为我先把(k+a_{kmod n})读成了(k+a_k mod n)然后发现房间号好像和样例算的不太对劲然后捣鼓一个小时最后发现其实读错题目了

    其实题目就是问这个房间号按照规则(k+a_{kmod n})之后是否会有重复,map大法好

    
    /*********************
    *@Author:   CKang    *
    *@Language: C++11    *
    *********************/
    #include<bits/stdc++.h>
    #pragma comment(linker, "/STACK:102400000,102400000")
    //#define DEBUG
    #define RI register int
    #define endl "
    "
    
    using namespace std;
    
    typedef long long ll;
    //typedef __int128 lll;
    //const int N=100000+10;
    const int M=100000+10;
    const int MOD=1e9+7;
    const double PI = acos(-1.0);
    const double EXP = 1E-9;
    const int INF = 0x3fffffff;
    const ll LINF = 0x3fffffffffffffff;
    
    inline ll read(){
        long long x=0,f=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){
            if(ch=='-')
                f=-1;
            ch=getchar();
        }
        while(ch>='0'&&ch<='9'){
            x=(x<<1)+(x<<3)+(ch^48);
            ch=getchar();
        }
        return x*f;
    }
    
    int a[200005]={0};map<int,int>mp;
    int n;
    void init(){
        for(int i=0;i<n;i++)a[i]=0;
        return;
    }
    
    void solve(){
        mp.clear();
        n=read();
        init();
        for(int i=0;i<n;i++){
            a[i]=read();
        }
    
        for(int i=0;i<n;i++){
            int tmp = ((i+a[i])%n+n)%n;//i+a[((a[i]%n)+n)%n];//i+a[i];//没错我就是看错题目瞎搞了
            if(mp[tmp]){
                puts("NO");
                return;
            }
            else mp[tmp]++;
        }
        puts("YES");
        return ;
    }
    
    int main()
    {
    #ifdef DEBUG
        freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout)
    #endif
        //cout.tie(0);
        for(ll t=read();t;t--)
            solve();
    #ifdef DEBUG
        printf("Time cost : %lf s
    ",(double)clock()/CLOCKS_PER_SEC);
    #endif
        //cout << "Fuck You !" << endl;
        return 0;
    }
    

    DEF等等会补的,今天心态崩了

    D.Monopole Magnets

    比较经典的DFS, 稍微理顺一点磁铁放置的规则(思维混乱,写的150+行像一坨屎就不放代码了)

  • 相关阅读:
    chmod命令
    ls命令
    数组值去重-小技巧
    使用redis接管session
    使用redis接管cookie
    redis操作封装类
    HTTP协议详解
    Linux网络编程--多播
    Live555 分析(三):客服端
    Live555 分析(二):服务端
  • 原文地址:https://www.cnblogs.com/--ChenShou--/p/12840209.html
Copyright © 2011-2022 走看看