ZOJ 3752 The Three Guys(暴力)
2016-04-15 21:05
246 查看
暴力枚举所有的长度可能
#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; }
相关文章推荐
- java入门
- UCOSIII怎么配置的时钟?(时钟源头选择,倍频)
- JS实现《黑客帝国》落地字母背景
- C++性能的优化
- CF 546A Soldier and Bananas
- service详细解读
- 102. Binary Tree Level Order Traversal
- Android:控件AutoCompleteTextView 自动提示
- Java 内存分配全面浅析 | Java基础
- 删除字符串中指定的字符
- 归并排序算法的实现
- 归并排序
- SPFA算法
- Struts2 JSONObject的使用
- 神经网络识别车牌字符
- 将博客搬至CSDN
- Sass入门——简介+语法格式及编译调试
- DataSet压缩,序列化
- 用脚本批量消除视频噪声
- 用脚本批量消除视频噪声