20200323(ABC)


传送门

今天比赛有点崩

A - Xenia and Divisors CodeForces - 342A

一共就三种情况,我这么写或许是有点麻烦。还有是要注意,用node定义map,node的变量都需要重载排个序

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],sum;
bool ok;
struct node{
	int x,y,z;
	bool operator <(const node &a)const {
		if(z==a.z&&y==a.y)
		return x<a.x;
		if(z==a.z&&x==a.x)
		return y<a.y;
    return z<a.z;
   }
};
map<node,int> q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	while(a[1]>0&&a[2]>0&&a[4]>0){
		node p;
		p.x=1;p.y=2;p.z=4;
		q[p]++;
		a[1]--;
		a[2]--;
		a[4]--;
		sum+=3;
	}
	while(a[1]>0&&a[2]>0&&a[6]>0){
		node p;
		p.x=1;p.y=2;p.z=6;
		q[p]++;
		a[1]--;
		a[2]--;
		a[6]--;
		sum+=3;
	}
	while(a[1]>0&&a[3]>0&&a[6]>0){
		node p;
		p.x=1;p.y=3;p.z=6;
		q[p]++;
		a[1]--;
		a[3]--;
		a[6]--;
		sum+=3;
	}
	if(sum!=n){
		cout<<"-1"<<endl;
		return 0;
	}
	for(map<node,int>::iterator it=q.begin();it!=q.end();it++){
		int t=it->second;
		while(t--){
			cout<<it->first.x<<" "<<it->first.y<<" "<<it->first.z<<endl;
		}
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],b[3],sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
    }
    while(a[1]>0&&a[2]>0&&a[4]>0){
    	b[0]++;
    	sum+=3;
    	a[1]--;a[2]--;a[4]--;
	}
    while(a[1]>0&&a[2]>0&&a[6]>0){
    	b[1]++;
    	sum+=3;
    	a[1]--;a[2]--;a[6]--;
	}
    while(a[1]>0&&a[3]>0&&a[6]>0){
    	b[2]++;
    	sum+=3;
    	a[1]--;a[3]--;a[6]--;
	}
	if(n!=sum){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<=2;i++){
		for(int j=1;j<=b[i];j++){
			if(i==0)
			cout<<1<<" "<<2<<" "<<4<<endl;
			if(i==1)
			cout<<1<<" "<<2<<" "<<6<<endl;
			if(i==2)
			cout<<1<<" "<<3<<" "<<6<<endl;
		}
	}
}

C - Cupboard and Balloons CodeForces - 342C

这道题是求容器里最多可以放多少小球。
分几种情况,第一种是顶部(也就是半球)可以最多可以放几个小球,可以是一个(最少)、二个、三个。当然了加上圆柱的数量

#include<bits/stdc++.h>
using namespace std;
double r,h,l;
int sum;
int main(){
	scanf("%lf%lf",&r,&h);
	sum+=int(h/r);
	l=h-r*sum;
	sum*=2;
	double r1=r+l;
	if(r1-(sqrt(3)+1)/2*r>=r/2){
		sum+=3;
		cout<<sum<<endl;
		return 0;
	}
	if(l>=r/2){
		sum+=2;
		cout<<sum<<endl;
		return 0;
	}
	else{
		sum+=1;
		cout<<sum<<endl;
		return 0;
	}
	cout<<sum<<endl;
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值