• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理
            //3348 Accepted 264K 0MS C++ 4016B 
            //典型的凸包和計算多邊形面積

            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>
            #include 
            <ctype.h>
            #include 
            <math.h>
            #include 
            <iostream>
            using namespace std ;
            #define unllong unsigned long long 
            #define unint unsigned int
            #define printline  printf( "\n" ) 
            typedef 
            long long llong ;
            //const double PI = 2.0 * acos( 0.0 ) ;
            #define zero(x) (((x)>0?(x):-(x))<eps)

            const int Base=1000000000;//高精度
            const int Capacity=100;//高精度
            const double eps = 1e-8 ;
            const int INF = 1000000 ;

            const int size = 10010 ;

            struct POINT
            {
                
            double x ;
                
            double y ;
                
            double k ;
            };
            struct POINT point[size] ;

            int stack[size] ; 
            int top = 2 ;

            int inn ;
            double outarea ;

            double fdist( double x1, double y1, double x2, double y2 )
            {
                
            return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;
            }

            void input()
            {
                
            int leftdown = 0 ;
                
            forint i=0; i<inn; i++ ) {
                    scanf( 
            "%lf %lf"&point[i].x, &point[i].y ) ;
                    
            //if( miny>point[i].y || miny==point[i].y&&minx>point[i].x )
                    if( point[leftdown].y>point[i].y||zero(point[leftdown].y-point[i].y)&&point[leftdown].x>point[i].x )
                        leftdown 
            = i ;//找到最左下的點
                }
                
            double temp ;
                temp 
            = point[0].x ; point[0].x = point[leftdown].x ; point[leftdown].x = temp ;
                temp 
            = point[0].y ; point[0].y = point[leftdown].y ; point[leftdown].y = temp ;
                
            forint i=1; i<inn; i++ ) {
                    point[i].k 
            = atan2( point[i].y-point[0].y, point[i].x-point[0].x ) ;
                }
            //以點(minx, miny)計算極角
            }

            double xmult( POINT &p1, POINT &p2, POINT &p0 )
            {
            //計算叉乘--線段旋轉方向和對應的四邊形的面積--返回(p1-p0)*(p2-p0)叉積
                
            //if叉積為正--p0p1在p0p2的順時針方向; if(x==0)共線

                
            return (p1.x-p0.x)*(p2.y-p0.y) - (p2.x-p0.x)*(p1.y-p0.y) ;
            }

            int gramcmp1( const void *a, const void *b )
            {
                
            struct POINT *= (struct POINT *)a ;
                
            struct POINT *= (struct POINT *)b ;

                
            if( c->- d->> eps )    return 1 ;
                
            else if( c->- d->< -1*eps ) return -1 ;
                
            else//斜率相等距離遠的點在先
                    return c->- d->> 0 ? 1 : -1 ;
            }

            int gramcmp( const void *a, const void *b )
            {
                
            struct POINT *= (struct POINT *)a ;
                
            struct POINT *= (struct POINT *)b ;

                
            double xmult_val = xmult( *c, *d, point[0] ) ;
                
            if( xmult_val > eps )    return -1 ;
                
            else if( xmult_val < -1*eps ) return 1 ;
                
            else return c->- d->> 0 ? 1 : -1 ;
                
            //else 
                
            //return fdist( c->x,c->y,point[0].x,point[0].y )>fdist(d->x,d->y,point[0].x,point[0].y)? -1:1 ;
            }

            void gramham()
            {
            //凸包的點存在于stack[]中
                qsort( point+1, inn-1sizeof(point[1]), gramcmp ) ;//極坐標排序--注意只有(n-1)個點

                
            //int stack[size] ; int top = 2 ;
                stack[0= 0 ; stack[1= 1 ; stack[2= 2 ; top  = 2 ;

                
            forint i=3; i<inn; i++ )
                {
                    
            while( top>=1&&xmult( point[i], point[stack[top]], point[stack[top-1]] )>=-1*eps ) 
                        top
            -- ;//順時針方向--刪除棧頂元素
                    stack[++top] = i ;//新元素入棧
                }
                
            /*
                for( int i=0; i<=top; i++ )
                {
                //printf( "%lf===%lf\n",point[stack[i]].x, point[stack[i]].y ) ;
                cout << point[stack[i]].x << "====" << point[stack[i]].y << endl ;
                }
                
            */
            }

            double flen_poly()
            {
            //計算凸包的周長
                double len = 0.0 ; double x1, x2, y1, y2 ;
                
            forint i=0; i<top; i++ ) {
                    x1 
            = point[stack[i+1]].x ; x2 = point[stack[i]].x ;
                    y1 
            = point[stack[i+1]].y ; y2 = point[stack[i]].y ;
                    len 
            += fdist( x1, y1, x2, y2 ) ;
                }
                x1 
            = point[stack[0]].x ; x2 = point[stack[top]].x ;
                y1 
            = point[stack[0]].y ; y2 = point[stack[top]].y ;
                len 
            += fdist( x1, y1, x2, y2 ) ;

                
            return len ;
            }

            double farea_poly( int n, POINT poly[] )
            {
                
            double area = 0.0 ; double s1 = 0.0 , s2 = 0.0 ;
                
            forint i=0; i<n; i++ )
                {
                    s1 
            += poly[stack[(i+1)%n]].y * poly[stack[i%n]].x ;
                    s2 
            += poly[stack[(i+1)%n]].y * poly[stack[(i+2)%n]].x ;
                }

                
            return fabs( s1 - s2 ) / 2 ;
            }

            void process()
            {
                gramham() ;
            //保存好凸包的點在stack[]中

                outarea 
            = farea_poly( top+1, point ) ;
            }

            void output()
            {
                printf( 
            "%d\n", (int)outarea/50 ) ;
            }

            int main()
            {
                
            //freopen( "fc.in", "r", stdin ) ;
                
            //freopen( "fc.out","w",stdout ) ;

                
            //freopen( "in.txt", "r", stdin ) ;

                
            while( scanf( "%d"&inn ) != EOF ) 
                {
                    input() ;

                    process() ;

                    output() ;
                }

                
            return 0 ;
            }
            99精品国产免费久久久久久下载| 天堂久久天堂AV色综合| 精品久久一区二区三区| 久久香蕉综合色一综合色88| 久久精品国产亚洲一区二区| 亚洲精品国产成人99久久| 久久亚洲国产成人影院网站| 日韩精品久久无码人妻中文字幕 | 99久久伊人精品综合观看| 久久se精品一区精品二区国产| 三级韩国一区久久二区综合| 久久精品午夜一区二区福利| 久久成人永久免费播放| 无码久久精品国产亚洲Av影片 | 久久国产精品无码HDAV| 久久久精品久久久久久| 日本人妻丰满熟妇久久久久久| 国产精品嫩草影院久久| 亚洲午夜久久久久妓女影院 | 99久久综合国产精品免费| 久久亚洲国产中v天仙www| 久久精品国产乱子伦| 九九久久精品无码专区| 99久久人妻无码精品系列蜜桃| 一本综合久久国产二区| 91精品国产综合久久香蕉| 精品国产乱码久久久久久郑州公司| 三级片免费观看久久| 久久精品免费网站网| 青青青国产精品国产精品久久久久| 亚洲中文字幕久久精品无码喷水| 青青青青久久精品国产h久久精品五福影院1421 | 久久国产精品-久久精品| 婷婷综合久久中文字幕蜜桃三电影| 久久久久久国产精品无码下载| 国产精品青草久久久久婷婷 | 久久精品成人免费观看97| 亚洲国产精品久久久久| 日韩精品国产自在久久现线拍| 久久精品国产99国产电影网| 一本久久久久久久|