zoukankan      html  css  js  c++  java
  • CodeForce Testing Round #16 (Unrated)

    不知道是人数的原因还是什么,这个比赛的体验超级棒

    A.A+B (Trial Problem)

    这就是基础的A+B,没啥好水的

    /*********************
    *@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 a=read(),b=read();
        cout<<a+b<<endl;
        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.Square?

    这个就是说给你两个矩形板子的尺寸,问你能不能拼成正方形。

    思路比较简单,一共只有4种拼法,稍微枚举一下

    /*********************
    *@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;
    }
    
    bool check(int a,int b,int c,int d){
        if(a==c)
            if(b+d==a)return true;
        if(a==d)
            if(b+c==a)return true;
        if(b==c)
            if(a+d==b)return true;
        if(b==d)
            if(a+c==b)return true;
        return false;
    }
    
    void solve(){
        ll a=read(),b=read(),c=read(),d=read();
        if(check(a,b,c,d))
            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;
    }
    

    C. Skier

    这个题目大概就是说有个人在瞎走,从出发点开始每次只能向一个方向走一个单位长度。假设原来在(0,0),向北走了一个单位之后就是(1,0),其他方向同理。如果这两个点之间是第一次走就要5s,否则只要1s,给你这个人的路径描述,求这个人的花费总时间。

    这个也就是模拟吧,对于当前位置和下一时刻的位置判断是否走过按照题目算时间即可,这里用了map+pair简单点

    /*********************
    *@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(){
        map<pair< pair< int , int > ,pair< int , int > > , int > mp ;
        string s;
        cin>>s;
        int x=0,y=0,ans=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='S'){
                int xx=x,yy=y-1;
                if(mp[{{x,y},{xx,yy}}]||mp[{{xx,yy},{x,y}}])
                    ans+=1;
                else {ans+=5;mp[{{x,y},{xx,yy}}]++;}
                x=xx;
                y=yy;
            }
            if(s[i]=='N'){
                int xx=x,yy=y+1;
                if(mp[{{x,y},{xx,yy}}]||mp[{{xx,yy},{x,y}}])
                    ans+=1;
                else {ans+=5;mp[{{x,y},{xx,yy}}]++;}
                x=xx;
                y=yy;
            }
            if(s[i]=='W'){
                int xx=x-1,yy=y;
                if(mp[{{x,y},{xx,yy}}]||mp[{{xx,yy},{x,y}}])
                    ans+=1;
                else {ans+=5;mp[{{x,y},{xx,yy}}]++;}
                x=xx;
                y=yy;
            }
            if(s[i]=='E'){
                int xx=x+1,yy=y;
                if(mp[{{x,y},{xx,yy}}]||mp[{{xx,yy},{x,y}}])
                    ans+=1;
                else {ans+=5;mp[{{x,y},{xx,yy}}]++;}
                x=xx;
                y=yy;
            }
        }
        cout<<ans<<endl;
        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;
    }
    
  • 相关阅读:
    本地SQL密码破解
    SqlServer2005复制分类
    xpsql.cpp: 错误 2 来自 CreateProcess(第 737 行)
    sql server 复制,镜像,日志传输及故障转移集群区别
    使用SQL操作MySQL数据库
    [技术文摘]Resin服务器的使用
    Tomcat新手攻略
    Java连接数据库谈
    jsp中文乱码问题的解决2
    台风来到
  • 原文地址:https://www.cnblogs.com/--ChenShou--/p/12846452.html
Copyright © 2011-2022 走看看