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

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

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

2019-11-14 12:08:13
字體:
來源:轉載
供稿:網友

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
日韩最新免费不卡| 欧美成人中文字幕| 国产精品久久久av久久久| 国产裸体写真av一区二区| 97视频在线观看免费高清完整版在线观看| 亚洲一品av免费观看| 成人久久精品视频| 欧美日韩性视频在线| 亚洲色图校园春色| 日韩欧美在线免费观看| 国产精品视频免费在线| 日韩av一区在线| 久久综合久中文字幕青草| 黄色成人av在线| 国内精品美女av在线播放| 亚洲精品电影网站| 亚洲四色影视在线观看| 亚洲成年人影院在线| 日韩激情片免费| 色偷偷av一区二区三区| 一本一道久久a久久精品逆3p| 91精品在线观看视频| 日韩精品高清在线| 亚洲成人黄色网| 国产精品三级网站| 96精品视频在线| 国产精品精品久久久久久| 中日韩美女免费视频网址在线观看| 欧美色欧美亚洲高清在线视频| 亚洲精品一区二区三区婷婷月| 国产欧美日韩亚洲精品| 国产69久久精品成人看| 久久国产一区二区三区| 久久人人爽人人爽人人片av高请| 久久精品久久久久久| 亚洲图片在区色| 全亚洲最色的网站在线观看| 国产亚洲精品一区二555| 精品久久久久久中文字幕大豆网| 精品福利免费观看| 成人精品一区二区三区电影黑人| 懂色av中文一区二区三区天美| 影音先锋日韩有码| 中文字幕精品一区久久久久| 免费成人高清视频| 久久久久久这里只有精品| 国产精品高潮呻吟久久av野狼| 丝袜亚洲欧美日韩综合| 岛国精品视频在线播放| 日本精品va在线观看| 日本亚洲欧美三级| 亚洲最大av网| 国产视频久久久久久久| 精品精品国产国产自在线| 日韩a**中文字幕| 国产精品久久久久久久av大片| 国产这里只有精品| 亚洲另类激情图| 亚洲自拍另类欧美丝袜| 欧美孕妇与黑人孕交| 韩国国内大量揄拍精品视频| 自拍偷拍亚洲精品| 久久久久亚洲精品成人网小说| 日韩精品久久久久久久玫瑰园| 欧美激情亚洲激情| 欧美国产高跟鞋裸体秀xxxhd| 久久久999精品| 一区二区三区精品99久久| 久久99亚洲热视| 久久久99免费视频| 亚洲欧美国产一区二区三区| 国语自产精品视频在线看| 狠狠躁夜夜躁人人爽天天天天97| 日韩av电影手机在线观看| 91精品国产91| 亚洲一级一级97网| 欧美国产日韩一区二区在线观看| 91在线视频成人| 日韩欧美在线网址| 久久天天躁狠狠躁夜夜爽蜜月| 91视频88av| 亚洲国产天堂久久综合网| 91最新国产视频| 91在线视频精品| 国产男女猛烈无遮挡91| 亚洲91精品在线观看| 国内精品400部情侣激情| 亚洲精品99999| 亚洲深夜福利网站| 午夜精品视频网站| 欧美性xxxx极品高清hd直播| 欧美电影免费在线观看| 亚洲精品99久久久久| www.久久色.com| 亚洲天堂精品在线| 久久久久久国产三级电影| 国产有码在线一区二区视频| 久久精品在线视频| 亚洲高清av在线| 欧美在线观看网站| 国产自产女人91一区在线观看| 欧美影院在线播放| 伊人伊成久久人综合网小说| 亚洲精品一区二三区不卡| 原创国产精品91| 性欧美暴力猛交69hd| 色狠狠久久aa北条麻妃| 亚洲精品在线视频| 最近中文字幕日韩精品| 欧美成人亚洲成人| 亚洲aⅴ日韩av电影在线观看| 国内外成人免费激情在线视频网站| 97在线免费观看视频| 亚洲精品一区二区网址| 亚洲精品视频免费| www.日韩免费| 成人黄色午夜影院| 欧美成人午夜免费视在线看片| 国产第一区电影| 国产精品久久久久久久久影视| 欧美视频免费在线| 国产免费一区视频观看免费| 亚洲xxxx视频| 午夜欧美大片免费观看| 97久久久免费福利网址| 国内精品中文字幕| 色诱女教师一区二区三区| 92国产精品久久久久首页| 亚洲理论电影网| 欧美日韩免费看| 国产亚洲视频在线观看| 日韩欧美视频一区二区三区| 8090成年在线看片午夜| 在线色欧美三级视频| 黑人狂躁日本妞一区二区三区| 成人免费高清完整版在线观看| 亚洲欧美日韩国产中文| 国产免费一区视频观看免费| 国语自产精品视频在线看| 欧美日韩国产在线| 国产精品精品视频一区二区三区| 欧美丝袜第一区| 国产69精品久久久久9| 青草青草久热精品视频在线观看| 日韩精品中文字幕有码专区| 538国产精品一区二区免费视频| 日本国产高清不卡| 国产精品美女无圣光视频| 91夜夜揉人人捏人人添红杏| 久久久久久香蕉网| 欧美激情极品视频| 欧美性69xxxx肥| 91av中文字幕| 亚洲成人精品久久久| 国产精品爱久久久久久久| 色偷偷91综合久久噜噜| 久久九九精品99国产精品| 国产精品一区二区三区久久久| 欧美大片在线看| 成人免费网视频| 66m—66摸成人免费视频| 日韩暖暖在线视频| 色偷偷9999www| 欧美日韩中文在线观看|