2021年浙大城市学院新生程序设计竞赛(同步赛)ABCDFHJ

A-All in!

#include<iostream>
using namespace std;
int main()
{
    cout<<"All in!"<<endl;
    return 0;
}

B-Boboge and Tall Building

题目大意:n,m,k表示一栋房子有m层楼,高为k,我住在第n层楼,问距离地面多远?

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,k;
        cin>>n>>m>>k;
        if(n==1) cout<<"0.0000000000"<<endl;
        else printf("%.10lf\n",(double)k*1.0*(n-1)/m);
    }
    return 0;
}

C-Constructive Problem

题目大意:给定一个整数n,构建一个长度为n的数组a,数组下标分别为a[0],a[1],,,a[n-1]。前提是它必须是一个漂亮数组:例如,当n==4的时候,a[0]=1; a[1]=2; a[2]=1; a[3]=0。0出现了一次,1出现了两次,2出现了1次,3出现了0次,所以这就构成了漂亮数组。

如果可以构建成漂亮数组,就输出数组,不能就输出-1。

金融学课堂离线摆烂。

手撕漂亮数组一个钟头,唔~

找规律:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int a[20020000];
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int n;
    cin>>n;
    if(n<=3||n==6) cout<<"-1"<<endl;
    else if(n==4) cout<<"1 2 1 0"<<endl;
    else if(n==5) cout<<"2 1 2 0 0"<<endl;
    else if(n==7) cout<<"3 2 1 1 0 0 0"<<endl;
    else
    {
        memset(a,0,sizeof a);
        //a[0]=n-4; a[1]=2; a[2]=1; a[n-4]=1;
        for(int i=0;i<n;i++)
        {
            if(i==0) a[0]=n-4;
            else if(i==1) a[1]=2;
            else if(i==2) a[2]=1;
            else if(i==n-4) a[n-4]=1;
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

 D-Diseased String

题目大意:求有几个ybb?(ybbb,ybbbb,ybbbbbbbbbbbb都各自算一个)。

#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        int sum=0;
        bool flag=false;
        for(int i=0;i<n;i++)
        {
            if(i+2<n&&s[i]=='y'&&s[i+1]=='b'&&s[i+2]=='b')
            {
                //cout<<i<<" ";
                sum++;
                i+=2;
                flag=true;
            }
            else if(flag==true&&s[i]=='b')
            {
                //cout<<i<<" ";
                sum++;
                flag=true;
            }
            else flag=false;
        }
        //cout<<endl;
        cout<<sum<<endl;
    }
    return 0;
}

F-Future Vision

题目大意:我必须在k-1分钟之前到达剑会到达的位置就可以成功拦截它。

 bfs 模板还是不太熟悉,唔~小细节卡人心态,还好是个友好的题目。

#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int,int> PII;
char a[2002][2002];
int dist[2002][2002];
int t,n,m;
int x,y;
int dx[]={-1,0,0,1},dy[]={0,1,-1,0};
int bfs()
{
    queue<PII> q;
    memset(dist,-1,sizeof dist);
    dist[x][y]=0;
    q.push({x,y});
    while(q.size())
    {
        auto t=q.front();
        q.pop();
        for(int i=0;i<4;i++)
        {
            int xx=t.first+dx[i],yy=t.second+dy[i];
            if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&a[xx][yy]!='#'&&dist[xx][yy]==-1)
            {
                dist[xx][yy]=dist[t.first][t.second]+1;
                q.push({xx,yy});
            }
        }
    }
    return dist[n][m];
}
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='H') x=i,y=j;
            }
        }
        bfs();
        /*for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                cout<<dist[i][j]<<" ";
            }
            cout<<endl;
        }
        cout<<endl;*/
        int k;
        cin>>k;
        int flag=-1;
        int minn=0x3f3f3f3f;
        for(int i=0;i<k;i++)
        {
            int A,B;
            cin>>A>>B;
            if(dist[A][B]!=-1&&dist[A][B]<=i)
            {
                flag=i;
                minn=min(i,minn);
            }
        }
        if(flag==-1) cout<<"NO"<<endl;
        else cout<<"YES "<<minn<<endl;
    }
    return 0;
}

J-Jiubei and Codeforces

题目大意:根据得分判断处在cf的什么名称,如果变化就输出名称之间的变化。

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<cstring>
using namespace std;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    /*3000+ Legendary grandmaster;
    1600-2999 International grandmaster;
    2400-2599 Grandmaster
    2300-2399 International master
    2100-2299 Master
    1900-2099 Candidate master
    1600-1899 Expert
    1400-1599 Specialist
    1200-1399 Pupil
    <1200 Newbie*/
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        string s;
        if(k>=3000) s="Legendary grandmaster";
        else if(k>=2600&&k<=2999) s="International grandmaster";
        else if(k>=2400&&k<=2599) s="Grandmaster";
        else if(k>=2300&&k<=2399) s="International master";
        else if(k>=2100&&k<=2299) s="Master";
        else if(k>=1900&&k<=2099) s="Candidate master";
        else if(k>=1600&&k<=1899) s="Expert";
        else if(k>=1400&&k<=1599) s="Specialist";
        else if(k>=1200&&k<=1399) s="Pupil";
        else if(k<1200) s="Newbie";
        while(n--)
        {
            int x;
            cin>>x;
            k+=x;
            string a=s;
            if(k>=3000) s="Legendary grandmaster";
            else if(k>=2600&&k<=2999) s="International grandmaster";
            else if(k>=2400&&k<=2599) s="Grandmaster";
            else if(k>=2300&&k<=2399) s="International master";
            else if(k>=2100&&k<=2299) s="Master";
            else if(k>=1900&&k<=2099) s="Candidate master";
            else if(k>=1600&&k<=1899) s="Expert";
            else if(k>=1400&&k<=1599) s="Specialist";
            else if(k>=1200&&k<=1399) s="Pupil";
            else if(k<1200) s="Newbie";
            if(a!=s){
            cout<<a<<" -> ";
            cout<<s<<endl;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}

(补题)H-Hile and Subsequences' MEX

f(n)=2^n-1。

(傻狗哭泣,自己做的时候找不着也推不出的痛,该补补排列组合了) 

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int mod=998244353;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL t;
    cin>>t;
    while(t--)
    {
        LL n;
        cin>>n;
        LL res=1,x=2;
        while(n)
        {
            if(n&1) res=res*x%mod;
            x=x*x%mod;
            n>>=1;
        }
        cout<<res-1<<endl;
    }
    return 0;
}

 摆烂~

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Vijurria

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值