hdu 6398 Pizza Hub

                                     Pizza Hub

Time Limit: 3000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 747    Accepted Submission(s): 161
Special Judge

 

Problem Description

Coffee Chicken has started a new restaurant named Pizza Hu...b! It provides various styles of pizzas, hamburgers, sandwiches, coffee, chickens and many other awesome Western cuisines. Welcome to Pizza Hub after this Multi-University Training Contest!

Since the pizzas are so exquisite, it is never a bad thing to design nice paper pads for them. The pizzas provided in Pizza Hub are sliced into triangles. The rectangular-shaped paper pads are cut from a paper strip of fixed width which is long enough. The pizza should be placed entirely on the pad; however, their borders are allowed to touch. Also, you are allowed to rotate the pizza.

As the customized paper strip is rather expensive, minimizing the size of the pizza pad can save a lot of money. Can you determine the minimum possible height of the pizza pad, given the width of the paper strip? The following picture illustrates the first sample test case.

 

 

Input

The first line of the input is a single integer T (1≤T≤50000), the number of test cases.

Each test case is a single line of seven integers x1,y1,x2,y2,x3,y3 (0≤x1,y1,x2,y2,x3,y3≤10000) and w (1≤w≤10000), where (x1,y1), (x2,y2) and (x3,y3)are Cartesian coordinates of the vertices of the pizza, and w is the width of the strip. It is guaranteed that the three vertices are not collinear.

 

 

Output

For each test case, display the minimum height of the pizza pad with an absolute or relative error of no more than 10−6. If it is impossible to make a pizza pad, display impossible instead.

 

 

Sample Input

 

2 0 0 3 0 0 4 10 0 0 3 0 0 4 1

 

 

Sample Output

 

2.400000000 impossible

Source

2018 Multi-University Training Contest 8

题意:给出三角形的三个坐标和矩形的宽,求出能够放进矩形的最小高度。

用向量来表示边的情况。

分一下情况:

向量a的那条边水平放置 

                               

向量a的那条边斜着放置

以下又分两种情况:向量b所在的那条边在向量a所在的那条边之上 ;

                                向量b所在的那条边在向量a所在的那条边之下 ;

            

 

#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
typedef  long long LL;
struct point
{
    LL x,y;
} p[15];
LL operator *(point A,point B)
{
    return A.x*B.x+A.y*B.y;
}
LL operator ^(point A,point B)
{
    return A.x*B.y-B.x*A.y;
}
point operator-(point A,point B)
{
    return (point)
    {
        A.x-B.x,A.y-B.y
    };
}
double sum;
void js(point a,point b,LL w)
{
    if(a*b<0)
        return ;
    if(a*a<=w*w)
    {
        if(a*b/sqrt(a*a)>w)
            return ;
        if((a^b)<0)
            return ;
        sum=min(sum,abs(a^b)/sqrt(a*a));
    }
    else
    {
        double h1=sqrt(a*a-w*w);
        double t1=atan(h1/w);
        double t2=PI/2-t1;
        if((a^b)>=0)
        {
            double s1=acos(a*b/(sqrt(a*a)*sqrt(b*b)));
            if(s1-t2>1e-9)
                return ;
            double L1=sqrt(b*b)*cos(s1+t1);
            if(L1-w>0)
                return ;
            double h2=sqrt(b*b)*sin(s1+t1);
            sum=min(sum,max(h1,h2));
        }
        else
        {
            double s1=acos(a*b/((sqrt(a*a)*sqrt(b*b))));
            if(s1-t1>1e-9)
                return ;
            double L1=sqrt(b*b)*cos(t1-s1);
            if(L1-w>0)
                return ;
            sum=min(sum,h1);
        }
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        LL w;
        for(int i=1; i<=3; i++)
        {
            scanf("%lld%lld",&p[i].x,&p[i].y);
        }
        scanf("%lld",&w);
        sum=1e9+7;
        js(p[3]-p[1],p[2]-p[1],w);
        js(p[2]-p[1],p[3]-p[1],w);
        js(p[3]-p[2],p[1]-p[2],w);
        js(p[1]-p[2],p[3]-p[2],w);
        js(p[1]-p[3],p[2]-p[3],w);
        js(p[2]-p[3],p[1]-p[3],w);
        for(int i=1; i<=3; i++)
        {
            p[i].y=-p[i].y;
        }
        js(p[3]-p[1],p[2]-p[1],w);
        js(p[2]-p[1],p[3]-p[1],w);
        js(p[3]-p[2],p[1]-p[2],w);
        js(p[1]-p[2],p[3]-p[2],w);
        js(p[1]-p[3],p[2]-p[3],w);
        js(p[2]-p[3],p[1]-p[3],w);
        if(sum>=1e9)
            printf("impossible\n");
        else
            printf("%.9f\n",sum);
    }
    return 0;
}

 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值