亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

POJ 1039-Pipe(計算幾何-線段相交、求交點)

2019-11-14 11:15:02
字體:
來源:轉載
供稿:網友

Pipe
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 10638 Accepted: 3293

Description

The GX Light Pipeline Company started to PRepare bent pipes for the new transgalactic light pipeline. During the design phase of the new pipe shape the company ran into the problem of determining how far the light can reach inside each component of the pipe. Note that the material which the pipe is made from is not transparent and not light reflecting. 
Each pipe component consists of many straight pipes connected tightly together. For the programming purposes, the company developed the description of each component as a sequence of points [x1; y1], [x2; y2], . . ., [xn; yn], where x1 < x2 < . . . xn . These are the upper points of the pipe contour. The bottom points of the pipe contour consist of points with y-coordinate decreased by 1. To each upper point [xi; yi] there is a corresponding bottom point [xi; (yi)-1] (see picture above). The company wants to find, for each pipe component, the point with maximal x-coordinate that the light will reach. The light is emitted by a segment source with endpoints [x1; (y1)-1] and [x1; y1] (endpoints are emitting light too). Assume that the light is not bent at the pipe bent points and the bent points do not stop the light beam.

Input

The input file contains several blocks each describing one pipe component. Each block starts with the number of bent points 2 <= n <= 20 on separate line. Each of the next n lines contains a pair of real values xi, yi separated by space. The last block is denoted with n = 0.

Output

The output file contains lines corresponding to blocks in input file. To each block in the input file there is one line in the output file. Each such line contains either a real value, written with precision of two decimal places, or the message Through all the pipe.. The real value is the desired maximal x-coordinate of the point where the light can reach from the source for corresponding pipe component. If this value equals to xn, then the message Through all the pipe. will appear in the output file.

Sample Input

40 12 24 16 460 12 -0.65 -4.457 -5.5712 -10.817 -16.550

Sample Output

4.67Through all the pipe.

Source

Central Europe 1995

題目意思:

給出管道上半部分各個拐點處的坐標(x,y),因為管道寬度為1,所以對應下半部分各個拐點處的坐標是(x,y-1)。

有一道光線從管道最左邊射入,光線不能穿透管壁也不能拐彎,求解它是否能穿過這個管道,如果不可以,輸出到達管中位置的最大橫坐標x。

解題思路:

先根據上下拐點的連線確定光線的入射斜率,枚舉其與各個拐點的上下連線是否有交點,因為有交點則說明光線可以穿過該段管道。如果光線能夠穿過管道,那么它將穿過每一段管道。

如果不能穿過,在第k節管道處無法穿過,則需要計算最大坐標x:

分別計算與第k-1節管子的上、下管壁相交, 求得最大坐標。

#include<iostream>#include<cstdio>#include<cmath>#include<iomanip>using namespace std;#define MAXN 30const int INF=1e9;const double eps=1e-3;struct point{    double x,y;};int sgn(double p)//對double確定精度{    if(fabs(p)<eps)  return 0;    return p>0?1:-1;}double circulation(point a,point b,point c)//計算向量BA、CA的叉積{    return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}double dir(point A,point B,point P)//計算P點在AB的左側還是右側(AC與AB的螺旋關系){    return circulation(A,B,P);}bool cross(point A,point B,point C,point D)//判斷線段AB和CD是否相交{    return (sgn(dir(A,B,C))*sgn(dir(A,B,D))<=0);}double intersection(point A,point B,point C,point D)//求AB與CD的交點x值{    double area1=dir(A,B,C);    double area2=dir(A,B,D);    int c=sgn(area1);    int d=sgn(area2);    if(c*d<0) //CD在AB的兩側,規范相交        return (area2*C.x - area1*D.x)/(area2-area1);//交點計算公式    if(c*d==0)   //CD的其中一個端點在AB上,不規范相交    {        if(c==0)            return C.x;//C在AB上,返回AB與CD非規范相交時的交點C的橫坐標        else            return D.x;//D在AB上,返回AB與CD非規范相交時的交點D的橫坐標    }    return -INF; //CD在AB同側,無交點,返回負無窮}int main(){#ifdef ONLINE_JUDGE#else    freopen("F:/cb/read.txt","r",stdin);    //freopen("F:/cb/out.txt","w",stdout);#endif    ios::sync_with_stdio(false);    cin.tie(0);    int n;    while(cin>>n&&n)//n表示管道的數目    {        point p[MAXN],q[MAXN];        for(int i=0; i<n; i++)        {            cin>>p[i].x>>p[i].y;            q[i].x=p[i].x;            q[i].y=p[i].y-1;        }        bool flag=false;        double ans=-INF;        int k;        for(int i=0; i<n; i++)//枚舉每段線段        {            for(int j=0; j<n; j++)            {                if(i==j) continue;                for(k=0; k<n; k++)//枚舉當前光線與第k個拐點處的上下連線是否相交                    if(!cross(p[i],q[j],p[k],q[k]))//掃描到一個不相交                        break;                if(k>=n)//與每個拐點處都相交                {                    flag=true;                    break;                }                else if(k>max(i,j))//不能穿過,求解最大x值                {                    double temp=intersection(p[i],q[j],p[k],p[k-1]);//求交點橫坐標                    if(ans<temp)//與第k-1節管子的上管壁相交                        ans=temp;                    temp=intersection(p[i],q[j],q[k],q[k-1]);                    if(ans<temp)//與第k-1節管子的上管壁相交                        ans=temp;                }            }            if(flag)//可穿                break;        }        if(flag)            cout<<"Through all the pipe."<<endl;        else            cout<<fixed<<setprecision(2)<<ans<<endl;    }    return 0;}/*40 12 24 16 460 12 -0.65 -4.457 -5.5712 -10.817 -16.550*/


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
91精品国产91久久久久久不卡| 久久人人爽人人爽人人片av高清| 亚洲电影免费在线观看| 日本19禁啪啪免费观看www| 精品国产91久久久| 欧美日韩国产中文精品字幕自在自线| 国产精品美女www爽爽爽视频| 国内精品一区二区三区| 欧美电影免费观看高清| 日韩成人av在线播放| 狠狠色狠狠色综合日日小说| 成人在线精品视频| 国产成人涩涩涩视频在线观看| 日韩二区三区在线| 国产成人午夜视频网址| 亚洲人成电影网站| 欧美精品在线观看91| 亚洲精品一区二区久| 国产中文日韩欧美| 亚洲精品成a人在线观看| 亚洲国产中文字幕在线观看| 欧美贵妇videos办公室| 欧美成人午夜剧场免费观看| 久久精品精品电影网| 国产区精品视频| www欧美日韩| 91高清视频免费观看| 国产精品69久久| 亚洲欧美日韩中文在线| 92看片淫黄大片看国产片| www.久久久久久.com| 91老司机精品视频| 日韩美女在线观看一区| 亚洲xxxx视频| 91久久久久久久久久久| 国产综合久久久久| 精品日韩视频在线观看| 国产美女精品免费电影| 中文字幕日韩av| 久久成人精品视频| 精品爽片免费看久久| 亚洲色图25p| 亚洲欧美一区二区三区久久| 久久久久久噜噜噜久久久精品| 91天堂在线视频| 国产91免费看片| 国产精品xxxxx| 欧美激情一级精品国产| 国产精品男女猛烈高潮激情| 国产精品美女无圣光视频| 色婷婷av一区二区三区在线观看| 成人深夜直播免费观看| 57pao国产成人免费| 国产在线精品成人一区二区三区| 久久视频在线直播| 欧美色欧美亚洲高清在线视频| 国产中文日韩欧美| 欧美日韩精品在线观看| 欧美国产日韩中文字幕在线| 欧美激情精品久久久久久变态| 欧美亚洲国产精品| 亚洲欧洲一区二区三区久久| 日韩电影大全免费观看2023年上| 97碰在线观看| 91在线观看免费高清| 亚洲精美色品网站| 欧美性做爰毛片| 国产精品久久久久影院日本| 91国产精品电影| 欧美精品一本久久男人的天堂| 欧美在线欧美在线| 永久555www成人免费| 在线观看91久久久久久| www欧美日韩| 欧美午夜性色大片在线观看| 亚洲精选中文字幕| 日韩在线欧美在线国产在线| 亚洲精品二三区| 777777777亚洲妇女| 插插插亚洲综合网| 日韩久久午夜影院| 91香蕉电影院| 久久视频免费观看| 一区二区三区四区视频| 国产精品高潮粉嫩av| 激情av一区二区| 91日韩在线播放| 日韩电影免费观看中文字幕| 国产欧美日韩最新| 久久视频在线播放| 成人xvideos免费视频| 中文字幕av一区| 亚洲字幕在线观看| 国产一区二区丝袜| 91亚洲va在线va天堂va国| 国外成人免费在线播放| 国产精品美女久久| 国产成人精品综合久久久| 韩国19禁主播vip福利视频| 亚洲毛茸茸少妇高潮呻吟| 日韩日本欧美亚洲| 日韩精品极品在线观看播放免费视频| 国产精品视频播放| 久久6免费高清热精品| 一区二区三区亚洲| 亚洲第一福利视频| 国产欧美日韩亚洲精品| 日本一区二区三区在线播放| 日韩av片电影专区| 欧美成人一区二区三区电影| 欧美精品精品精品精品免费| 久久久成人的性感天堂| 亚洲影视九九影院在线观看| 国产精品r级在线| 日韩高清免费在线| 亚洲人成网7777777国产| 欧美激情在线观看| 欧美精品video| 国产成人黄色av| 亚洲国产精品久久91精品| 日韩美女免费视频| 日韩视频免费在线观看| 亚洲激情视频在线| 中文字幕亚洲第一| 91精品国产91久久久久久| 欧美性猛交xxxx偷拍洗澡| 国产精品久久久久久超碰| 性欧美xxxx视频在线观看| 亚洲va男人天堂| 欧美黄色www| 中文字幕综合一区| 欧美日韩成人黄色| 精品自拍视频在线观看| 在线不卡国产精品| 伊人av综合网| 国产91精品高潮白浆喷水| 日韩最新在线视频| 国产成人精品久久二区二区| 欧美大成色www永久网站婷| 国产激情久久久| 欧美激情第一页xxx| 庆余年2免费日韩剧观看大牛| 亚洲国产日韩欧美在线图片| 91久久久精品| 日韩av电影院| 欧美疯狂xxxx大交乱88av| 亚洲男人第一av网站| 日韩视频免费在线| 91亚洲精品视频| 久热精品视频在线观看| 午夜精品在线观看| 国内免费久久久久久久久久久| 亚洲一区二区三区sesese| 国产亚洲精品91在线| 成人国内精品久久久久一区| 国产精品丝袜视频| 日韩大陆欧美高清视频区| 清纯唯美日韩制服另类| 国产精品亚洲精品| 亚洲情综合五月天| 色噜噜狠狠狠综合曰曰曰88av| 日韩在线中文字幕| 亚洲国产小视频在线观看| 国产剧情久久久久久|