• 2020牛客暑期多校训练营(第三场)


     签到题

    L Problem L is the Only Lovely Problem


      

    先大小写统一化,判断前六个字母是不是"lovely",是,打印"lovely",否,打印"ugly"

    代码

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    int main()
    {
        string s;
        string s1;
        s1="";
        cin>>s;
        for(int i=0; i<s.length(); i++)
        {
            if(s[i]>='A'&&s[i]<='Z')
            {
                s[i]+=32;
            }
        }
        if(s[0]=='l'&&s[1]=='o'&&s[2]=='v'&&s[3]=='e'&&s[4]=='l'&&s[5]=='y')
        {
            cout<<"lovely"<<endl;
        }
        else
        {
            cout<<"ugly"<<endl;
        }
    }
    A Clam and Fish

     

    type1:无鱼,无蛤蜊

    type2:无鱼,有蛤蜊

    type3:有鱼,无蛤蜊

    type4:有鱼,无蛤蜊

    思路

    有鱼的时候钓鱼;没有鱼但有蛤蜊时,做饵料;无鱼无蛤蜊时,若有饵料的话,可以钓鱼,如果没有的话,什么事也不用干。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int t,i;
        scanf("%d",&t);
        int n;
    
        char s[2000005];
        while(t--)
        {int yu=0,er=0;
            scanf("%d%s",&n,s);
            for(i=0;i<n;i++)
            {
                if(s[i]=='2'||s[i]=='3')
                {
                    yu++;
                }
                else if(s[i]=='0')
                {
                    if(er)
                    {
                        er--;
                        yu++;
                    }
                }
                else if(s[i]=='1')
                {
                    er++;
                }
            }
            printf("%d
    ",yu+er/2);
        }
    }
    B Classical String Problem

    规律题,暴力必t

    视初始字符串都首字母为标准,每次移动标记好当前首字母的位置,如若首字母位置超过字符串长度则取模字符串长度;若首字母位置小于0则仅需加上字符串长度即可。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    int main()
    {
        string s;
        int t;
        cin>>s>>t;
        int l=s.length();
        int x=0;
        int i;
        char c;
        int n;
        for(i=0;i<t;i++)
        {
            cin>>c>>n;
            if(c=='A')
            {
                printf("%c
    ",s[(n+x-1)%l]);
            }
            else if(c=='M')
            {
                x=x+n;
                if(x<0)
                {
                    x=x+l;
                }
    
            }
        }
    }

     

     

     

  • 相关阅读:
    在Windows Server 2008 R2上安装IIS服务
    Linux 系统化学习系列文章总目录(持续更新中)
    Oracle 11g一步步安装详解
    MySQL 菜鸟入门“秘籍”
    Linux下的/proc目录介绍
    Python查找文件
    Python对文件和文件路径的管理
    Python中执行外部命令
    Python处理命令行参数
    CentOS7--TigerVNC
  • 原文地址:https://www.cnblogs.com/jackwang-sparrow/p/13369004.html
Copyright © 2020-2023  润新知