• <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++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

            公告

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

            常用鏈接

            留言簿(4)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新隨筆

            最新評(píng)論

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

            閱讀排行榜

            評(píng)論排行榜

            #include <iostream>
            #include 
            <math.h>
            #include 
            <string.h>
            #define eps 1e-7

            using namespace std;

            struct point{
                
            double x, y;
                
            void read(){scanf("%lf %lf"&x, &y);}
                
            void write(){printf("%.2lf %.2lf\n", x, y);}
                point 
            operator-(point &a)
                {
                    point t;
                    t.x 
            = x - a.x;
                    t.y 
            = y - a.y;
                    
            return t;
                }
                point 
            operator+(point &a)
                {
                    point t;
                    t.x 
            = x + a.x;
                    t.y 
            = y + a.y;
                    
            return t;
                }
            };

            int n;
            point p[
            105];

            double dist(point a, point b)
            {
                point c 
            = a - b;
                
            return sqrt( c.x * c.x + c.y * c.y);
            }

            bool flag;

            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;
            }


            point change(point a, point b, point next, 
            double L)
            {
                point t;
                t.x 
            = -(b - a).y;
                t.y 
            = (b - a).x;
                
            double len = sqrt(t.x * t.x + t.y * t.y);
                t.x 
            /= len;        t.y /= len;
                t.x 
            *= L; t.y *= L;
                t 
            = t + next;
                
            return t;
            }

            int jud(double h)
            {
                point tp[
            105], tt[105], ns, ne, s, e, pp ;
                
            int len = 0, tlen, i, j;

                
            for(i = 0; i <= n; i ++) tp[i] = p[i];
                len 
            = n;
                
                
            for(i = 0; i < n; i ++)
                {
                    s 
            = change(p[i], p[i + 1], p[i], h);
                    e 
            = change(p[i], p[i + 1], p[i + 1], h); 
                    
            //        s.write();
            //        e.write();
                    
                    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];
            //            printf("point:   ");
            //            tp[j].write();
                    }
                    len 
            = tlen;
            //        printf("%d\n", len);
                }
                
            return len;
            }

            double bsearch(double left, double right)
            {    
                
            while(right-left>eps)
                {
                    
            double mid=(left+right)/2;
            //        printf("%lf %lf %lf:\n", left, mid, right);
                    if(jud(mid))left=mid;
                    
            else          right=mid;
                }
                
            return left; 

                
            }

            int main()
            {
                
            while(scanf("%d"&n), n)
                {
                    
            for(int i = 0; i < n; i ++)
                        p[i].read();    
                    p[n] 
            = p[0];
                    
            double minn = -1, maxx = -1;
                    
            for(int i = 0; i < n; i ++)
                    
            for(int j = i + 1; j < n; j ++)
                    {
                        
            double dis = dist(p[i], p[j]) / 2;
                        
            if(dis < minn || minn < eps)
                            minn 
            = dis;
                        
            if(dis > maxx || maxx < eps)
                            maxx 
            = dis;
                    }
                    flag 
            = 0;
                    
            //printf("%.2lf  %.2lf\n", minn, maxx); while(1);
                    double ans = bsearch(0, maxx);
                    printf(
            "%.6lf\n", ans);
                }
            }

            posted on 2009-09-18 21:10 superlong 閱讀(477) 評(píng)論(0)  編輯 收藏 引用

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


            久久91精品国产91久| 久久亚洲国产成人影院网站| 久久人做人爽一区二区三区 | 日韩一区二区三区视频久久| 久久久久国色AV免费看图片| 亚洲国产精品狼友中文久久久| 午夜精品久久久久久久无码| 久久人人爽爽爽人久久久| 99久久精品日本一区二区免费| 久久99久久99小草精品免视看| 久久电影网| 国产午夜福利精品久久2021| 久久99精品免费一区二区| 伊人久久精品无码二区麻豆| 日韩一区二区久久久久久| 亚洲欧美一级久久精品| 国产精品久久久久AV福利动漫| 亚洲国产成人精品91久久久 | 久久99免费视频| 久久精品卫校国产小美女| 国产ww久久久久久久久久| 人妻少妇久久中文字幕一区二区| 久久WWW免费人成—看片| 亚洲AV无码成人网站久久精品大| 日本免费久久久久久久网站| 久久亚洲精品国产精品| 模特私拍国产精品久久| 久久久久国色AV免费看图片| 色综合久久88色综合天天| 久久久久人妻一区精品色| 少妇无套内谢久久久久| 亚洲欧洲中文日韩久久AV乱码| 久久精品成人免费国产片小草| 久久久久久免费一区二区三区| 久久久久亚洲av无码专区| 亚洲va久久久噜噜噜久久天堂| 久久无码中文字幕东京热| 色诱久久av| 亚洲午夜精品久久久久久浪潮 | 久久精品国产精品亚洲下载| 91精品国产91久久久久久蜜臀|