天梯赛真题补题单(L1-1 ~ L1-5)

L1-1 寻找250

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL x;
        LL idx=0;
        while(cin>>x)
        {
            idx++;
            if(x==250)
            {
                cout<<idx<<endl;
                break;
            }
        }
    }
    return 0;
}

L1-2 日期格式化

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL a,b,c;
        char s1,s2;
        scanf("%d-%d-%d",&a,&b,&c);
        printf("%d-%02d-%02d",c,a,b);
    }
    return 0;
}

L1-3 阅览室

注意小细节

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
struct node
{
    LL first=-1,second=-1;
}mp[1050];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL t;
        cin>>t;
        LL sum=0,avg=0;
        for(int i=1;i<=t;i++)
        {
            for(int i=0;i<=1024;i++)
            {
                mp[i].first=-1;
                mp[i].second=-1;
            }
            while(1)
            {
                LL x;
                string s;
                LL a,b;
                char c;
                cin>>x>>s>>a>>c>>b;
                if(x!=0)
                {
                    LL num=a*60+b;
                    if(s=="S") mp[x].first=num;
                    else
                    {
                        if(mp[x].first!=-1)
                        {
                            mp[x].second=num;
                            sum++;
                            avg+=abs(mp[x].first-mp[x].second);
                            mp[x].first=-1;
                            mp[x].second=-1;
                        }
                    }
                }
                else
                {
                    if(sum!=0)
                    {
                        printf("%lld %.0lf\n",sum,(double)avg/sum);
                    }
                    else printf("0 0\n");
                    sum=0,avg=0;
                    break;
                }
            }
        }
    }
    return 0;
}

L1-4 稳赢

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL t;
        cin>>t;
        string s;
        LL idx=0;
        while(cin>>s)
        {
            if(s=="End") break;
            idx++;
            if(idx%(t+1)==0) cout<<s<<endl;
            else
            {
                if(s=="ChuiZi") cout<<"Bu"<<endl;
                else if(s=="JianDao") cout<<"ChuiZi"<<endl;
                else cout<<"JianDao"<<endl;
            }
        }
    }
    return 0;
}

L1-5 宇宙无敌大招呼

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        cout<<"Hello "<<s<<endl;
    }
    return 0;
}
posted @ 2024-04-14 19:24  Vijurria  阅读(5)  评论(0编辑  收藏  举报