• <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>

            學(xué)習(xí)心得(code)

            superlong@CoreCoder

              C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

            公告

            文字可能放在http://blog.csdn.net/superlong100,此處存放代碼

            常用鏈接

            留言簿(4)

            我參與的團隊

            搜索

            •  

            最新隨筆

            最新評論

            • 1.?re: Poj 1279
            • 對于一個凹多邊形用叉積計算面積 后能根據(jù)結(jié)果的正負(fù)來判斷給的點集的時針方向?
            • --bsshanghai
            • 2.?re: Poj 3691
            • 你寫的這個get_fail() 好像并是真正的get_fail,也是說fail指向的串并不是當(dāng)前結(jié)點的子串。為什么要這樣弄呢?
            • --acmer1183
            • 3.?re: HDU2295[未登錄]
            • 這個是IDA* 也就是迭代加深@ylfdrib
            • --superlong
            • 4.?re: HDU2295
            • 評論內(nèi)容較長,點擊標(biāo)題查看
            • --ylfdrib
            • 5.?re: HOJ 11482
            • 呵呵..把代碼發(fā)在這里很不錯..以后我也試試...百度的編輯器太爛了....
            • --csuft1

            閱讀排行榜

            評論排行榜

            #include <iostream>
            #include 
            <math.h>
            #include 
            <string>
            using namespace std;

            int n;

            struct point
            {
                
            double x, y;
                
            void write(){printf("%.2lf %.2lf\n", x, y);}
            };

            point p[
            1505];
            bool  h[1505];

            double xmul(point a, point b, point c)
            {
            return (c.x - a.x) * (b.y - a.y) - (c.y - a.y) * (b.x - a.x);}

            point intersection(point u1,point u2,point v1,point v2){
                point ret
            =u1;
                
            double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))
                        
            /((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));
                ret.x
            +=(u2.x-u1.x)*t;
                ret.y
            +=(u2.y-u1.y)*t;
                
            return ret;
            }

            void read()
            {
                scanf(
            "%d"&n);
                
            for(int i = 0; i < n; i ++)
                    scanf(
            "%lf %lf"&p[i].x, &p[i].y);
                p[n] 
            = p[0];
            }
            double cross(point a, point b)
            {
            return a.x * b.y - a.y * b.x;}

            double area(point *p, int n)//面積為負(fù)多邊形為順時針給出
            {
                
            double sum = 0;
                
            for(int i = 0; i < n; i ++)
                    sum 
            += cross(p[i], p[i + 1]);
                
            return sum / 2;
            }

            void pre()
            {
                point tp[
            1505];
                
            if(area(p, n) < 0)
                {
                    
            for(int i = 0; i < n; i ++)
                        tp[i] 
            = p[n - 1 - i];
                    tp[n] 
            = tp[0];
                    
            for(int i = 0; i <= n; i ++) p[i] = tp[i];
                }
                
            }

            void solve()
            {
                
            int i, j, flag;
                
            double sum;
                point tp[
            1505], tt[1505], ns, ne;
                
            int len = 0, tlen;
                point s, e, pp;
                memset(h, 
            0sizeof(h));

                
            //enum
                for(i = 0; i <= n; i ++) tp[i] = p[i];
                len 
            = n;
                
                
            for(i = 0; i < n; i ++)
                {
            //        for(j = 0; j < len; j ++)
            //            printf("<%.2lf %.2lf> \n",tp[j].x, tp[j].y);
            //        puts("");
                    
                    s 
            = p[i];    e = p[i + 1];
                    tlen 
            = 0;
                    
                    
            for(j = 0; j < len; j ++)
                    {
                        ns 
            = tp[j];    ne = tp[j + 1];
                        
            if(xmul(s, e, ns) <= 0)
                            tt[tlen 
            ++= ns;
                        
            if(xmul(s, e, ns) * xmul(s, e, ne) < 0)
                        {
                            pp 
            = intersection(s, e, ns, ne);
                            
                            tt[tlen 
            ++= pp;
                        }    
                    }
                    tt[tlen] 
            = tt[0];
                    
            for(j = 0; j <= tlen; j ++) tp[j] = tt[j];
                    len 
            = tlen;
                }
                
                
            //core
                tp[len] = tp[0];
                sum 
            = area(tp, len);
                printf(
            "%.2lf\n", fabs(sum));
            }

            int main()
            {
                
            int test;
                scanf(
            "%d"&test);
                
            while(test --)
                {
                    read();
                    pre();
                    solve();
                }
            }

            posted on 2009-08-29 16:32 superlong 閱讀(638) 評論(1)  編輯 收藏 引用

            Feedback

            # re: Poj 1279 2012-04-21 01:02 bsshanghai
            對于一個凹多邊形用叉積計算面積 后能根據(jù)結(jié)果的正負(fù)來判斷給的點集的時針方向?  回復(fù)  更多評論
              


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久亚洲AV成人无码软件| 久久精品天天中文字幕人妻 | 久久久久久国产精品免费无码| 中文字幕久久久久人妻| 久久男人Av资源网站无码软件| 2020最新久久久视精品爱| 一级女性全黄久久生活片免费 | 午夜精品久久影院蜜桃| 亚洲中文字幕久久精品无码APP | 亚洲国产婷婷香蕉久久久久久| 亚洲欧美成人综合久久久| 欧美久久综合性欧美| 亚洲国产精品一区二区三区久久 | 囯产精品久久久久久久久蜜桃| 久久综合九色综合精品| 波多野结衣AV无码久久一区| segui久久国产精品| 久久亚洲AV成人出白浆无码国产| 久久亚洲中文字幕精品一区| 久久九九全国免费| 伊人久久大香线蕉综合Av| 波多野结衣久久精品| 久久这里有精品视频| 精品久久久久久无码中文字幕| 久久精品aⅴ无码中文字字幕不卡| 97精品伊人久久大香线蕉| 久久一本综合| 久久天天日天天操综合伊人av| 久久精品一区二区国产| 久久精品国产亚洲av麻豆蜜芽| 伊人久久一区二区三区无码| 亚洲欧美国产精品专区久久| 国产激情久久久久影院小草| 久久亚洲国产欧洲精品一| 久久青青草原精品国产| 国产精品无码久久综合| www.久久热.com| 97精品伊人久久久大香线蕉| 国产精品青草久久久久福利99| 久久成人精品| 免费精品国产日韩热久久|