首页 > 其他分享 >AcWing 第 90 场周赛 ABC

AcWing 第 90 场周赛 ABC

时间:2023-02-11 20:22:14浏览次数:70  
标签:周赛 ABC const string minn int LL cin 90

(我又来水博客了)才五天没写题,打成这样子,会被自己气sha

https://www.acwing.com/activity/content/2870/

AcWing 4806. 首字母大写

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        if(s[0]>=65&&s[0]<=92) cout<<s<<endl;
        else
        {
            s[0]-=32;
            cout<<s<<endl;
        }
    }
    return 0;
}

AcWing 4807. 找数字

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL m,s;
        cin>>m>>s;
        LL ss=s;
        bool flag=true;
        string minn,maxn;
        s-=1;
        for(int i=m;i>=2;i--)
        {
            if(s>=9)
            {
                minn+='9';
                s-=9;
            }
            else if(s!=0)
            {
                minn+=to_string(s);
                s=0;
            }
            else if(s==0) minn+='0';
        }
        minn+=to_string(s+1);
        reverse(minn.begin(),minn.end());
        //cout<<minn<<endl;

        if(minn.size()!=m) flag=false;

        for(int i=1;i<=m;i++)
        {
            if(ss>=9)
            {
                maxn+='9';
                ss-=9;
            }
            else if(ss!=0)
            {
                maxn+=to_string(ss);
                ss=0;
            }
            else if(ss==0) maxn+='0';
        }
        if(ss!=0) flag=false;
        if(maxn.size()!=m) flag=false;

        if(flag==false) cout<<"-1 -1"<<endl;
        else cout<<minn<<" "<<maxn<<endl;

    }
    return 0;
}

AcWing 4808. 构造字符串

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        string s;
        cin>>s;
        string ccc=s;
        s=" "+s;
        LL idx=0;
        for(LL i=1;i<s.size()-1;i++)
        {
            string c=s.substr(s.size()-i,i);
            string be=s.substr(1,i);
            //cout<<be<<" "<<c<<endl;
            if(be==c) idx=max(idx,i);
        }
        //cout<<idx<<endl;
        string ans=ccc;
        string flag=ccc.substr(idx);
        //cout<<flag<<endl;
        for(int i=1;i<m;i++)
            ans+=flag;
        cout<<ans<<endl;
    }
    return 0;
}

标签:周赛,ABC,const,string,minn,int,LL,cin,90
From: https://www.cnblogs.com/Vivian-0918/p/17112491.html

相关文章