青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

coreBugZJ

此 blog 已棄。

EOJ 1189 Wall POJ 1113 Wall

  1/*
  2EOJ 1189 Wall
  3POJ 1113 Wall
  4
  5
  6----問題描述:
  7
  8Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a beautiful brick wall with a perfect shape and nice tall towers. Instead, he ordered to build the wall around the whole castle using the least amount of stone and labor, but demanded that the wall should not come closer to the castle than a certain distance. If the King finds that the Architect has used more resources to build the wall than it was absolutely necessary to satisfy those requirements, then the Architect will loose his head. Moreover, he demanded Architect to introduce at once a plan of the wall listing the exact amount of resources that are needed to build the wall.
  9
 10Your task is to help poor Architect to save his head, by writing a program that will find the minimum possible length of the wall that he could build around the castle to satisfy King's requirements.
 11
 12The task is somewhat simplified by the fact, that the King's castle has a polygonal shape and is situated on a flat ground. The Architect has already established a Cartesian coordinate system and has precisely measured the coordinates of all castle's vertices in feet. 
 13
 14
 15----輸入:
 16
 17Input contains several test cases. The first line of each case contains two integer numbers N and L separated by a space. N (3 <= N <= 1000) is the number of vertices in the King's castle, and L (1 <= L <= 1000) is the minimal number of feet that King allows for the wall to come close to the castle.
 18
 19Next N lines describe coordinates of castle's vertices in a clockwise order. Each line contains two integer numbers Xi and Yi separated by a space (-10000 <= Xi, Yi <= 10000) that represent the coordinates of ith vertex. All vertices are different and the sides of the castle do not intersect anywhere except for vertices.
 20 
 21Process to end of file. 
 22
 23
 24----輸出:
 25
 26For each case in the input, write to the output file the single number that represents the minimal possible length of the wall in feet that could be built around the castle to satisfy King's requirements. You must present the integer number of feet to the King, because the floating numbers are not invented yet. However, you must round the result in such a way, that it is accurate to 8 inches (1 foot is equal to 12 inches), since the King will not tolerate larger error in the estimates.
 27
 28
 29----樣例輸入:
 30
 319 100
 32200 400
 33300 400
 34300 300
 35400 300
 36400 400
 37500 400
 38500 200
 39350 200
 40200 200 
 41
 42
 43----樣例輸出:
 44
 451628
 46
 47
 48----分析:
 49
 50Graham-Scan 求凸包,再根據(jù)夾角,求弧長(zhǎng),而總弧長(zhǎng)就是周長(zhǎng)。
 51
 52
 53*/

 54
 55
 56#include <iostream>
 57#include <cstdio>
 58#include <cmath>
 59#include <algorithm>
 60
 61using namespace std;
 62
 63// #define  TEST
 64
 65#define  N  1009
 66typedef  pair< intint > Point;
 67#define  y  first
 68#define  x  second
 69#define  PI  3.14159265358979
 70
 71int    n;
 72int    le;
 73Point  p[ N ];
 74
 75double solve() {
 76        static Point stk[ N ];
 77        int    tp, i, ntp;
 78        double ans = 0;
 79
 80        sort( p, p+n );
 81
 82#ifdef  TEST
 83        for ( i = 0; i < n; ++i ) {
 84                printf( "x = %d  y = %d\n", p[ i ].x, p[ i ].y );
 85        }

 86#endif
 87
 88        tp = 0;
 89        stk[ tp ] = p[ 0 ];
 90        for ( i = 1; i < n; ++i ) {
 91                while ( (0 < tp) && 
 92                        ((stk[tp].x-stk[tp-1].x)*(p[i].y-stk[tp].y) - 
 93                         (p[i].x-stk[tp].x)*(stk[tp].y-stk[tp-1].y) <= 0
 94                      ) {
 95                                --tp;
 96                }

 97                ++tp;
 98                stk[ tp ] = p[ i ];
 99        }

100
101#ifdef  TEST
102        printf( "stk 1\n" );
103        for ( i = 0; i <= tp; ++i ) {
104                printf( "stk x = %d  y = %d\n", stk[ i ].x, stk[ i ].y );
105        }

106#endif
107
108        ntp = tp; // 左右鏈必須分開處理,點(diǎn)(n-1)左右鏈共用
109        for ( i = n-2; i >= 0--i ) {
110                while ( (ntp < tp) && 
111                        ((stk[tp].x-stk[tp-1].x)*(p[i].y-stk[tp].y) - 
112                         (p[i].x-stk[tp].x)*(stk[tp].y-stk[tp-1].y) <= 0
113                      ) {
114                                --tp;
115                }

116                ++tp;
117                stk[ tp ] = p[ i ];
118        }

119
120#ifdef  TEST
121        printf( "stk all\n" );
122        for ( i = 0; i <= tp; ++i ) {
123                printf( "stk x = %d  y = %d\n", stk[ i ].x, stk[ i ].y );
124        }

125#endif
126
127        for ( i = 0; i < tp; ++i ) {
128                ans += sqrt((double)( 
129                                (stk[i].x-stk[i+1].x)*(stk[i].x-stk[i+1].x) 
130                                + (stk[i].y-stk[i+1].y)*(stk[i].y-stk[i+1].y) 
131                        ));
132        }

133
134        ans += 2 * PI * le;
135        return ans;
136}

137
138int main() {
139        int i;
140        while ( 2 == scanf( "%d%d"&n, &le ) ) {
141                for ( i = 0; i < n; ++i ) {
142                        scanf( "%d%d"&(p[ i ].x), &(p[ i ].y) );
143                }

144                printf( "%0.0lf\n", solve() );
145        }

146        return 0;
147}

148

posted on 2012-05-13 22:52 coreBugZJ 閱讀(756) 評(píng)論(0)  編輯 收藏 引用 所屬分類: ACMAlgorithm課內(nèi)作業(yè)

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美专区中文字幕| 国产精品久久福利| 影音先锋一区| 另类图片综合电影| 久久躁日日躁aaaaxxxx| 精品成人一区二区三区四区| 蜜桃久久av| 嫩草成人www欧美| 日韩系列在线| 在线亚洲+欧美+日本专区| 国产精品成人一区二区网站软件| 亚洲视频在线观看一区| 亚洲一区视频在线观看视频| 韩国在线一区| 欧美电影免费观看| 欧美日韩免费高清一区色橹橹| 亚洲一区精彩视频| 欧美一区二区三区四区在线观看地址 | 亚洲激情网站| 99re热精品| 国产日韩在线看| 欧美风情在线观看| 欧美亚洲成人免费| 久热精品在线| 欧美日韩国产三级| 国产一区av在线| 欧美顶级大胆免费视频| 欧美日韩人人澡狠狠躁视频| 久久蜜桃香蕉精品一区二区三区| 欧美电影免费观看大全| 欧美与黑人午夜性猛交久久久| 日韩香蕉视频| 狠狠综合久久| 国产精品99久久久久久www| 一区二区三区在线看| 99精品热视频只有精品10| 红桃视频一区| 一区二区三区www| 亚洲国产你懂的| 欧美一区二区三区免费看| 在线亚洲精品| 美腿丝袜亚洲色图| 久久久九九九九| 欧美日韩一二三四五区| 欧美a级片一区| 国产一区二区三区视频在线观看| 9l视频自拍蝌蚪9l视频成人| 亚洲国产成人久久综合| 性高湖久久久久久久久| 亚洲亚洲精品三区日韩精品在线视频 | 亚洲一级二级| 欧美精品xxxxbbbb| 欧美激情五月| 黄色成人精品网站| 亚洲色图在线视频| 99热精品在线观看| 欧美+日本+国产+在线a∨观看| 久久黄色级2电影| 国产精品一区二区在线观看不卡| 亚洲肉体裸体xxxx137| 影音先锋久久精品| 欧美诱惑福利视频| 久久精品最新地址| 国产日韩欧美一区二区三区在线观看 | 日韩午夜三级在线| 免费久久精品视频| 亚洲国产精品va在线看黑人动漫| 尤物在线精品| 久久久精品一品道一区| 久久这里有精品视频| 国产三级精品三级| 亚洲欧美日韩中文在线制服| 亚洲免费视频一区二区| 国产精品a久久久久久| 这里只有精品视频| 亚洲欧美国内爽妇网| 国产精品老牛| 午夜亚洲福利| 美女视频黄 久久| 在线精品一区二区| 欧美va亚洲va香蕉在线| 亚洲黄色在线| 亚洲在线电影| 国产一区二区精品久久| 毛片一区二区| 亚洲每日更新| 久久99在线观看| 亚洲电影免费观看高清完整版在线 | 性久久久久久久久久久久| 国产美女搞久久| 久久久久高清| 亚洲精品久久嫩草网站秘色| 亚洲欧美日韩成人高清在线一区| 国产一区二区三区四区老人| 久久婷婷国产综合精品青草| 亚洲精品中文字幕在线| 欧美一区二区黄| 亚洲第一主播视频| 欧美日韩国产91| 欧美亚洲网站| 日韩午夜中文字幕| 久久天堂成人| 亚洲一区精品在线| 国产主播精品在线| 欧美日韩第一区日日骚| 欧美在线播放一区| 91久久夜色精品国产九色| 欧美一区二区播放| 亚洲青涩在线| 国产一区二区成人| 欧美日韩在线三级| 免费成人美女女| 亚洲女人天堂av| 亚洲日韩视频| 欧美jizzhd精品欧美喷水| 亚洲欧美国产va在线影院| 亚洲精品免费在线播放| 韩国三级电影一区二区| 国产精品v一区二区三区| 美玉足脚交一区二区三区图片| 亚洲小说春色综合另类电影| 亚洲高清不卡在线| 久久亚洲私人国产精品va| 亚洲永久免费观看| 亚洲精品国产精品乱码不99按摩 | 欧美体内谢she精2性欧美| 久久九九免费| 亚洲欧美国产va在线影院| 亚洲精品视频一区| 欧美国产日本在线| 久久亚洲综合网| 久久狠狠久久综合桃花| 小嫩嫩精品导航| 亚洲一区二区视频在线观看| 亚洲精品在线三区| 亚洲激情欧美| 亚洲第一福利视频| 激情伊人五月天久久综合| 国模私拍一区二区三区| 国产亚洲精品高潮| 国产亚洲免费的视频看| 国产美女精品视频| 国产伦精品一区二区三区视频孕妇| 欧美性猛片xxxx免费看久爱| 欧美日韩国产探花| 欧美另类久久久品| 欧美女同在线视频| 欧美激情亚洲国产| 欧美韩日视频| 欧美日韩在线另类| 国产精品成人观看视频免费| 欧美日韩国产123| 欧美日韩国产三级| 国产精品久久久久久久久免费樱桃| 欧美视频观看一区| 国产精品扒开腿做爽爽爽软件| 国产精品久久二区| 国产亚洲精品自拍| 一色屋精品亚洲香蕉网站| 亚洲大片av| 最近中文字幕mv在线一区二区三区四区 | 久久国产一区二区三区| 久久久福利视频| 欧美gay视频| 欧美日韩极品在线观看一区| 国产精品成人免费| 国产日韩欧美亚洲| 亚洲国产精品成人综合色在线婷婷| 亚洲精品一区在线| 亚洲素人一区二区| 欧美中文字幕在线| 欧美成人a∨高清免费观看| 亚洲欧洲精品成人久久奇米网| 99精品久久免费看蜜臀剧情介绍| 中文精品视频| 久久久精品国产免大香伊| 欧美老女人xx| 国产三级精品三级| 亚洲人成网站色ww在线| 欧美一区二区三区另类| 美女视频黄a大片欧美| 日韩午夜中文字幕| 久久九九热免费视频| 欧美日韩视频一区二区三区| 国产日韩欧美一区在线 | 欧美午夜不卡视频| 国产色爱av资源综合区| 亚洲精品影院| 久久精品青青大伊人av| 日韩网站在线观看| 久久久久久久国产| 国产精品卡一卡二卡三| 亚洲精品麻豆| 久久人人爽人人爽| 亚洲视频一二三| 欧美激情视频在线免费观看 欧美视频免费一 | 国产欧美日韩综合一区在线播放| 亚洲高清激情| 久久久99爱| 亚洲欧美成人一区二区在线电影 |