ZOJ 3752 The Three Guys(暴力)

暴力枚举所有的长度可能


#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;  
const int maxn = 57;  
#define MAXN 100005
#define ll long long

struct node
{
	int pos;
	int a,b;
	friend bool operator<(const node &x,const node &y)
	{
		return x.pos<y.pos;
	}
};

bool cheak(int a,int b,int c)
{
	int d[3]={a,b,c};
	sort(d,d+3);
	if(d[0]+d[1]>d[2])return true;
	return false;
}

double getS(int a,int b,int c)
{
	double p=(a+b+c)/2.0;
	return sqrt(p*(p-a)*(p-b)*(p-c));
}

int main()
{
	node a[3];
	while(cin>>a[0].a>>a[0].b)
	{
		int all=0;
		for(int i=1;i<3;i++)
		{scanf("%d%d",&a[i].a,&a[i].b),all+=a[i].a,all+=a[i].b;}
		all+=a[0].a,all+=a[0].b;
		a[0].pos=0;a[1].pos=1,a[2].pos=2;
		double ans=0.0;
		do
		{
			for(int i=0;i<2;i++)
			{
				swap(a[0].a,a[0].b);
				for(int j=0;j<2;j++)
				{
					swap(a[1].a,a[1].b);
					for(int k=0;k<2;k++)
					{
						swap(a[2].a,a[2].b);
						vector<int >q;
						for(int in=0;in<3;in++)q.push_back(a[in].a),q.push_back(a[in].b);
						for(int hu=0;hu<6;hu++)
						{
							int duan1,duan2,duan3;
							for(int p1=0;p1<6;p1++)
							{
								duan1=0;
								for(int pp1=0;pp1<=p1;pp1++)
									duan1+=q[pp1];
								for(int p2=p1+1;p2<6;p2++)
								{
									duan2=0;
									for(int pp2=p1+1;pp2<=p2;pp2++)duan2+=q[pp2];
									duan3=all-duan1-duan2;
									if(cheak(duan1,duan2,duan3))
									{
										ans=max(ans,getS(duan1,duan2,duan3));
									}
								}
							}
							int temp=q[0];
							q.erase(q.begin());
							q.push_back(temp);
						}
					}
				}
			}
		}while(next_permutation(a,a+3));
		printf("%.12f\n",ans);
	}
	return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值