zoukankan      html  css  js  c++  java
  • Codeforces Round #556 (Div. 2)-ABC(这次的题前三题真心水)

    A. Stock Arbitraging

    直接上代码:

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<map>
    #include<vector>
    #include<cmath>
    
    
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
    
    int main()
    {
        
        int n,m,r;
        cin>>n>>m>>r;
        int x;
        int minn=0x3f3f3f3f;
        for(int t=0;t<n;t++)
        {
            scanf("%d",&x);
            minn=min(minn,x);
        }
        int maxnn=0;
        for(int t=0;t<m;t++)
        {
            scanf("%d",&x);
            maxnn=max(maxnn,x);
        }
        if(maxnn<=minn)
        {
            cout<<r<<endl;
        }
        else
        {
            int k=r;
            r=r%minn;
            r+=(maxnn)*(k/minn);
            cout<<r<<endl;
        }
        
        return 0;
    }

    B. Tiling Challenge

    找一下就行了

    代码:

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<map>
    #include<vector>
    #include<cmath>
    
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
    char Map[55][55];
    int n;
    int dir[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
    bool check(int x,int y)
    {
        if(x>=0&&x<n&&y>=0&&y<n)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    int main()
    {
        
        cin>>n;
        getchar();
        for(int t=0;t<n;t++)
        {
            scanf("%s",Map[t]);
        }
        for(int t=0;t<n;t++)
        {
            for(int j=0;j<n;j++)
            {
                int sum=0;
                if(Map[t][j]=='.')
                {
                for(int k=0;k<4;k++)
                {
                    int xx=t+dir[k][0];
                    int yy=j+dir[k][1];
                    //cout<<xx<<" "<<yy<<endl;
                    if(check(xx,yy)&&Map[xx][yy]=='.')
                    {
                        sum++;
                    }
                }
                }
                if(sum==4)
                {
                    Map[t][j]='#';
                    for(int k=0;k<4;k++)
                    {
                    int xx=t+dir[k][0];
                    int yy=j+dir[k][1];
                    Map[xx][yy]='#';
                    }
                }
            }
        }
        bool flag=true;
        for(int t=0;t<n;t++)
        {
            for(int j=0;j<n;j++)
            {
                if(Map[t][j]=='.')
                {
                    flag=false;
                }
            }
        }
        if(flag)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
        return 0;
    }

    C. Prefix Sum Primes

    思维+构造也很好想

    代码;

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<map>
    #include<vector>
    #include<cmath>
    
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
    vector<int>v1,v2;
    int main()
    {
        int n;
        cin>>n;
        int x;
        for(int t=0;t<n;t++)
        {
            scanf("%d",&x);
            if(x==1)
            v1.push_back(x);
            else
            {
                v2.push_back(x);
            }
        }
        
        if(v1.size()==n)
        {
            vector<int>::iterator it=v1.begin();
            for(it=v1.begin();it!=v1.end();it++)
            {
                cout<<*it<<" ";
            }
        }
        else if(v2.size()==n)
        {
            vector<int>::iterator it=v2.begin();
            for(it=v2.begin();it!=v2.end();it++)
            {
                cout<<*it<<" ";
            }
        }
        else
        {
          cout<<"2 1 ";
          int xx=v1.size()-1;
          int yy=v2.size()-1;
          for(int t=0;t<yy;t++)
          {
              cout<<"2 ";
          }
          for(int j=0;j<xx;j++)
          {
              cout<<"1 ";
          }
            
            
        }
        return 0;
    }
  • 相关阅读:
    Mayan游戏 (codevs 1136)题解
    虫食算 (codevs 1064)题解
    靶形数独 (codevs 1174)题解
    黑白棋游戏 (codevs 2743)题解
    神经网络 (codevs 1088) 题解
    The Rotation Game (POJ 2286) 题解
    倒水问题 (codevs 1226) 题解
    银河英雄传说 (codevs 1540) 题解
    生日蛋糕 (codevs 1710) 题解
    第一章 1.11 高阶函数
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10795288.html
Copyright © 2011-2022 走看看