当前位置:   article > 正文

Mynavi Programming Contest 2021(AtCoder Beginner Contest 201)_atcoder201

atcoder201

A - Tiny Arithmetic Sequence

void solves(){
	for(int i=0;i<3;++i) cin>>a[i];
	sort(a,a+3);
	if(a[2]+a[0]==2*a[1]){
		cout<<"Yes"<<endl;
	} else cout<<"No\n";
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

B - Do you know the second highest mountain?

bool cmp(pair<string,int>a,pair<string,int>b){
	return a.second>b.second;
}
void solves(){
	int n;cin>>n;
	vector<pair<string,int>>a(n);
	for(int i=0;i<n;++i){
		cin>>a[i].first>>a[i].second;
	}
	sort(a.begin(),a.end(),cmp);
	cout<<a[1].first<<endl;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

C - Secret Number

可能是高中的排列组合大题

先阐述一下不同种类的小球构成的长度为4的排列的一般性。
一种小球可以构成的排列有1种。
两种小球的话就列举一下有14种,如
A B B B A A B B A A A B ABBB \qquad AABB \qquad AAAB ABBBAABBAAAB
     C 4 1 + C 4 2 ∗ C 2 2          +        C 4 1 \;\;C_4^1 \qquad + C_4^2*C_2^2 \;\;\;\; + \;\;\; C_4^1 C41+C42C22+C41
三种小球可以隔板, C 3 1 ∗ C 3 1 ∗ C 4 1 = 36 C_3^1*C_3^1*C_4^1=36 C31C31C41=36
四种小球 A 4 4 = 24 A_4^4=24 A44=24

然后记certain的数量为c,not sure的数量为re。对c进行讨论。
c=0时,可能选取re的数量分别为1 2 3 4。
C r e 1 ∗ 1 + C r e 2 ∗ 14 + C r e 3 ∗ 36 + C r e 4 ∗ 24 C_{re}^1*1+C_{re}^2*14+C_{re}^3*36+C_{re}^4*24 Cre11+Cre214+Cre336+Cre424
c=1时,可能选取re的数量分别为1 2 3。
1 + C r e 1 ∗ 14 + C r e 2 ∗ 36 + C r e 3 ∗ 24 1+C_{re}^1*14+C_{re}^2*36+C_{re}^3*24 1+Cre114+Cre236+Cre324
c=2时,可能选取re的数量分别为1 2。
14 + C r e 1 ∗ 36 + C r e 2 ∗ 24 14+C_{re}^1*36+C_{re}^2*24 14+Cre136+Cre224
c=3时,可能选取re的数量为1。
36 + C r e 1 ∗ 24 36+C_{re}^1*24 36+Cre124
c=4时, A 4 4 = 24 A_4^4=24 A44=24
需要特判c>4或c=0,re=0的情况

void solves(){
	string s;cin>>s;
	int c=0,re=0;
	for(auto x:s){
		if(x=='o') c++;
		if(x=='?') re++;
	}
	if(c>4||(!c&&!re)){
		cout<<0<<endl; return;
	}
	int ans=0;
	if(c==1){
		ans+=1;
		ans+=re*14;
		ans+=(re-1)*re*18;
		ans+=(re-2)*(re-1)*re*4;
	}
	if(c==2){
		ans+=14;
		ans+=(re-1)*re*12;
		ans+=re*36;
	}
	if(c==3){
		ans+=36;
		ans+=re*24;
	}
	if(c==4)ans+=24;
	if(!c&&re){
		ans+=re+(re-1)*re*7+(re-2)*(re-1)*re*6+(re-3)*(re-2)*(re-1)*re;
	}
	cout<<ans<<endl;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/52665
推荐阅读
相关标签
  

闽ICP备14008679号