ZOJ 3752 The Three Guys
2014-01-29 20:31
169 查看
The Three Guys
三个人围成一个圆圈,所以a,b,c和a,c,b等组合其实是相同的。
只要考虑这个人是顺时针还是逆时针即可,有8种情况。
对于每种情况,6个线段围成一圈,分成三角形的三条边,求面积即可
#include<cstdio>
#include<iostream>
#include<string.h>
#include<cmath>
using namespace std;
double ans;
double s(double len1,double len2,double len3)
{
double t=(len1+len2+len3)/2;
double c=t*(t-len1)*(t-len2)*(t-len3);
if(c<=0) return -1;
return sqrt(c);
}
void circle(double l1,double l2,double l3,double l4,double l5,double l6){
double a[14]={l1,l2,l3,l4,l5,l6};
for(int i=0;i<6;i++)
for(int j=i+1;j<6;j++)
for(int k=j+1;k<6;k++){
double len1=0,len2=0,len3=0;
for(int p=i;p<j;p++) len1+=a[p];
for(int p=j;p<k;p++) len2+=a[p];
for(int p=k;p<i+6;p++) len3+=a[p%6];
//printf("%lf %lf %lf =%lf\n",len1,len2,len3,s(len1,len2,len3));
ans=max(ans,s(len1,len2,len3));
}
}
int main(){
double u1,u2,u3,l1,l2,l3;
while(cin>>u1>>l1>>u2>>l2>>u3>>l3){
ans=0;
circle(u1,l1,u2,l2,u3,l3);//顺顺顺
circle(u1,l1,u2,l2,l3,u3);//顺顺逆
circle(u1,l1,l2,u2,u3,l3);//顺逆顺
circle(u1,l1,l2,u2,l3,u3);//顺逆逆
circle(l1,u1,u2,l2,u3,l3);//逆顺顺
circle(l1,u1,u2,l2,l3,u3);//逆顺逆
circle(l1,u1,l2,u2,u3,l3);//逆逆顺
circle(l1,u1,l2,u2,l3,u3);//逆逆逆
printf("%.9lf\n",ans);
}
return 0;
}
三个人围成一个圆圈,所以a,b,c和a,c,b等组合其实是相同的。
只要考虑这个人是顺时针还是逆时针即可,有8种情况。
对于每种情况,6个线段围成一圈,分成三角形的三条边,求面积即可
#include<cstdio>
#include<iostream>
#include<string.h>
#include<cmath>
using namespace std;
double ans;
double s(double len1,double len2,double len3)
{
double t=(len1+len2+len3)/2;
double c=t*(t-len1)*(t-len2)*(t-len3);
if(c<=0) return -1;
return sqrt(c);
}
void circle(double l1,double l2,double l3,double l4,double l5,double l6){
double a[14]={l1,l2,l3,l4,l5,l6};
for(int i=0;i<6;i++)
for(int j=i+1;j<6;j++)
for(int k=j+1;k<6;k++){
double len1=0,len2=0,len3=0;
for(int p=i;p<j;p++) len1+=a[p];
for(int p=j;p<k;p++) len2+=a[p];
for(int p=k;p<i+6;p++) len3+=a[p%6];
//printf("%lf %lf %lf =%lf\n",len1,len2,len3,s(len1,len2,len3));
ans=max(ans,s(len1,len2,len3));
}
}
int main(){
double u1,u2,u3,l1,l2,l3;
while(cin>>u1>>l1>>u2>>l2>>u3>>l3){
ans=0;
circle(u1,l1,u2,l2,u3,l3);//顺顺顺
circle(u1,l1,u2,l2,l3,u3);//顺顺逆
circle(u1,l1,l2,u2,u3,l3);//顺逆顺
circle(u1,l1,l2,u2,l3,u3);//顺逆逆
circle(l1,u1,u2,l2,u3,l3);//逆顺顺
circle(l1,u1,u2,l2,l3,u3);//逆顺逆
circle(l1,u1,l2,u2,u3,l3);//逆逆顺
circle(l1,u1,l2,u2,l3,u3);//逆逆逆
printf("%.9lf\n",ans);
}
return 0;
}
相关文章推荐
- ZOJ-3752-The Three Guys【暴力】
- ZOJ 3752 The Three Guys(暴力)
- ZOJ - 3752 The Three Guys
- zoj 3228 Searching the String (ac自动机)
- zoj3432——Find the Lost Sock
- Find the maximum of the three numbers(Take this opportunity to review the sorting algorithm)
- zoj 1654 Place the Robots 二分图匹配
- ZOJ 3582 Back to the Past(概率DP)
- zoj2818 Root of the Problem 简单数学 开方
- ZOJ 3547 《The Boss on Mars》(容斥定理)
- ZOJ-1610- Count the Colors(端点染色,Lazy算法)
- ZOJ 3229 Shoot the Bullet
- poj1122&&zoj1053 FDNY to the Rescue! ——最短路入门题_Dijkstra算法
- ZOJ 3466 The Hive II
- [转]how to split the ng-repeat data with three columns using bootstrap
- ZOJ 3605 Find the Marble(三维dp)
- ZOJ-2770 Burn the Linked Camp
- zoj 1610 Count the Colors(线段树)
- zoj2110-Tempter of the Bone
- ZOJ - 3195 Design the city