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

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

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

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

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
亚洲欧美在线第一页| 色噜噜狠狠狠综合曰曰曰| 欧美一级片久久久久久久| 欧美国产在线视频| 亚洲永久在线观看| 欧美一区二区三区免费视| 亚洲一区www| 日韩av资源在线播放| 久久精品久久久久久国产 免费| 亚洲国产精品成人va在线观看| 久久av红桃一区二区小说| 国产成人精品国内自产拍免费看| 久久久噜噜噜久久| 91精品久久久久久久久中文字幕| 亚洲精品国产综合久久| 日韩激情av在线免费观看| 欧美大片在线看免费观看| 茄子视频成人在线| 91亚洲精品在线观看| 57pao成人国产永久免费| 国产精品成人va在线观看| 日本电影亚洲天堂| 日韩在线视频线视频免费网站| 成人午夜小视频| 欧美午夜无遮挡| 国产丝袜一区二区三区| 91亚洲精品久久久久久久久久久久| 欧美电影院免费观看| 日韩中文字幕第一页| 久久精品免费播放| 久久人人爽人人爽人人片av高清| 欧美日韩亚洲一区二区三区| 韩国19禁主播vip福利视频| 国产精品国产三级国产aⅴ浪潮| 欧美电影免费观看高清完整| 亚洲欧美精品中文字幕在线| 在线播放日韩精品| 成人网在线视频| 日韩免费观看网站| 国产91热爆ts人妖在线| 国产色婷婷国产综合在线理论片a| 日本欧美精品在线| 国产视频精品久久久| 欧美成人精品xxx| 国产日韩欧美夫妻视频在线观看| 欧美第一黄网免费网站| 国产精品盗摄久久久| 国产免费一区二区三区香蕉精| 欧美影院在线播放| 国产成人精品免费视频| 亚洲精品videossex少妇| 日韩精品免费在线视频| 日本久久亚洲电影| 欧美黑人视频一区| 日韩欧美aⅴ综合网站发布| 国产精品人成电影| 成人免费午夜电影| 日韩亚洲成人av在线| 欧美成人免费全部| 日本电影亚洲天堂| 国产精品福利在线| 精品国产户外野外| 亚洲老头老太hd| 日本精品中文字幕| 亚洲美女激情视频| 国产精品久久久久久久久久免费| 青青久久av北条麻妃黑人| 国产精品久久久久久久7电影| 精品呦交小u女在线| 国内精品久久久久影院 日本资源| 欧美xxxx18性欧美| 国产精品久久久久久婷婷天堂| 日韩精品福利网站| 日韩av日韩在线观看| 中文国产成人精品| 精品久久久久久久中文字幕| 欧美又大又粗又长| 欧美老少做受xxxx高潮| 国产精品黄页免费高清在线观看| 欧美尺度大的性做爰视频| 国产日韩欧美日韩大片| 亚洲国产精品久久久久秋霞不卡| 亚洲丝袜av一区| 日韩精品久久久久| 在线观看中文字幕亚洲| 亚洲91精品在线观看| 色www亚洲国产张柏芝| 91香蕉嫩草神马影院在线观看| 88国产精品欧美一区二区三区| 久久精彩免费视频| 日韩最新中文字幕电影免费看| 亚洲美女av网站| 欧美日本精品在线| 国产一区二区三区网站| 91精品国产91久久久久| 日韩国产在线播放| 夜色77av精品影院| 亚洲成**性毛茸茸| 欧美精品手机在线| 国产精品日韩电影| 美日韩精品视频免费看| 精品偷拍各种wc美女嘘嘘| 国产精品视频网站| 在线观看欧美成人| 成人国产精品av| 91精品国产91久久久久福利| 黄色精品在线看| 久久久999国产| 国产精品第七影院| 日韩电影中文字幕av| 亚洲国产成人久久综合一区| 久久伊人精品天天| 九九精品在线观看| 色综合视频一区中文字幕| 热久久99这里有精品| 亚洲人成电影在线观看天堂色| 免费成人高清视频| 午夜精品久久久久久久99黑人| 久久国内精品一国内精品| 久久久精品国产亚洲| 国产成人一区二| 欧美日韩精品在线播放| 激情成人在线视频| 777国产偷窥盗摄精品视频| 欧美高跟鞋交xxxxxhd| yw.139尤物在线精品视频| 国产精品久久久久久久久久小说| 久久久久久国产精品三级玉女聊斋| 日韩欧美综合在线视频| 一区二区三区国产视频| 久久精品久久久久久| 亚洲国产古装精品网站| 欧美xxxx14xxxxx性爽| 国产精品国产自产拍高清av水多| 久久综合免费视频影院| 国产亚洲精品91在线| 亚洲天堂男人天堂| 国产精品日韩一区| 久久久这里只有精品视频| 色爱精品视频一区| 欧美一级大片在线观看| 久久这里只有精品99| 色777狠狠综合秋免鲁丝| 亚洲社区在线观看| 欧美日韩激情美女| 亚洲欧美日韩网| 久久综合免费视频| 欧洲日本亚洲国产区| 欧美成人性色生活仑片| 日韩美女av在线| 性夜试看影院91社区| 成人精品aaaa网站| 欧美成人精品在线观看| 精品香蕉在线观看视频一| 色综合伊人色综合网站| 欧美精品18videos性欧美| 亚洲欧洲在线播放| 亚洲毛片在线观看| 色综合久久久久久中文网| 国产精品久久久久久五月尺| 国产丝袜一区二区三区免费视频| 国产精品成人国产乱一区| 亚洲在线免费视频| 欧美裸体男粗大视频在线观看|