2021-12-3【AtCoder Beginner Contest 230】【题解A-D】

A - AtCoder Quiz 3

题目详情

在这里插入图片描述
问题说明
AtCoder Grand Contest(AGC)是一个定期举行的具有世界权威性的比赛,已经举行了54次。

就像第230届ABC–也就是你现在所在的那届–被称为ABC230一样,第N届AGC最初是以一个零填充的3位数N来命名的。(第1届AGC是AGC001,第2届AGC是AGC002,…)。

然而,最新的第54个AGC被称为AGC055,其中的数字是比54大一个。因为AGC042由于社会情况而被取消和缺失,所以第42次和以后的比赛被分配的号码比所举行的比赛的数量大一。(参见样本输入和输出的解释)。

问题是:给定一个整数N,以AGCXXX的格式打印第N个AGC的名称,其中XXX是加零的3位数字。

code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn=1e6+5;
void solve(){
	int n;
	cin>>n;
	if(n>=42)
		printf("AGC%03d", n + 1);
	else
		printf("AGC%03d", n);
}

int main(){
	solve();
	return 0;
}

B - Triple Metre

题目大意

在这里插入图片描述

code


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn=1e6+5;
void solve(){
	string t="oxxoxxoxxoxxoxxoxxoxxoxxoxxoxx";
	string s;
	cin>>s;
	for(int i=0;i<t.size();i++){
		if(t.substr(i,s.size())==s){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
}

int main(){
	ios::sync_with_stdio(0);
	solve();
	return 0;
}


C - X drawing

题目大意

在这里插入图片描述

code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn=1e6+5;
void solve() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll P, Q, R, S;
	cin >> P >> Q >> R >> S;
	for (ll i = P; i <= Q; ++i) {
		for (ll j = R; j <= S; ++j)
			if (abs(A - i) == abs(j - B)) {
				cout << "#";
			} else {
				cout << ".";
			}
		cout << "\n";
	}
}
int main(){
	ios::sync_with_stdio(0);
	int t;
	t=1 ;
	while(t--){
		 solve();
	}
	return 0;
}

D - Destroyer Takahashi

题目大意

在这里插入图片描述

code


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define ff first
#define ss second
const int maxn=1e6+5;
void solve(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].ss>>v[i].ff;
    }
    sort(v.begin(),v.end());
    int r=INT_MIN,ans=0;
    for(pair<int,int> p:v){
        if(r+k-1>=p.ss){
            continue;
        }
        r=p.ff;
        ans+=1;
    }
    cout<<ans<<"\n";
}
int main(){
	ios::sync_with_stdio(0);
	int t;
	t=1 ;
	while(t--){
		 solve();
	}
	return 0;
}

推荐:我的专栏数据结构

或者进入2021-10-16【严蔚敏数据结构代码实现合集】【c语言学习必备】学习


🚩🚩🚩有问题欢迎评论区留言讨论,看到后我就会回复的!!!!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Eternity_GQM

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

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

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

打赏作者

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

抵扣说明:

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

余额充值