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

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>
            狠狠色综合网| 久久国产精品亚洲va麻豆| 亚洲激情国产| 中文av一区特黄| 久久久久中文| 中文成人激情娱乐网| 久久久国产视频91| 国产精品高潮粉嫩av| 亚洲国产综合91精品麻豆| 午夜亚洲福利在线老司机| 亚洲国产精品传媒在线观看| 欧美怡红院视频一区二区三区| 欧美精品一区二区三区一线天视频 | 国产精品你懂的在线| 亚洲人成毛片在线播放女女| 久久精品人人做人人综合| 日韩亚洲不卡在线| 欧美成年人视频网站| 狠狠色狠狠色综合日日五| 欧美高清视频在线| 久久婷婷国产综合精品青草| 国产一区二区按摩在线观看| 亚洲免费一级电影| 亚洲深夜av| 在线播放精品| 欧美大片专区| 国产精品极品美女粉嫩高清在线 | 久久人人97超碰国产公开结果 | 久久视频在线免费观看| 99天天综合性| 亚洲精品美女在线观看| 欧美电影在线观看完整版| 亚洲欧美激情一区| 美国三级日本三级久久99| 亚洲电影在线免费观看| 蜜桃av一区二区| 久久久美女艺术照精彩视频福利播放| 国产日韩av高清| 久久婷婷av| 免费观看不卡av| 日韩亚洲成人av在线| 亚洲精品裸体| 亚洲夫妻自拍| 欧美一级专区免费大片| 影音先锋日韩资源| 亚洲欧美日韩综合| 在线观看亚洲| 欧美亚洲免费电影| 亚洲专区国产精品| 欧美一区二区免费| 亚洲综合成人婷婷小说| 欧美国产综合视频| 亚洲免费在线播放| 欧美日韩高清不卡| 欧美一区深夜视频| 欧美wwwwww| 蜜桃久久av一区| 激情久久久久久| 亚洲精品一区二区三区av| 国产精品美女久久久久久2018| 亚洲国产婷婷| 亚洲乱码国产乱码精品精 | 欧美一区二区高清在线观看| 欧美伦理a级免费电影| 欧美第一黄色网| 亚洲国产影院| 欧美/亚洲一区| 亚洲电影免费在线观看| 国产精品久久久久久久9999| 一区二区三区.www| 亚洲国产精品成人一区二区| 久久精品国产清自在天天线| 久久夜色精品亚洲噜噜国产mv| 国产在线播放一区二区三区| 亚洲伦伦在线| 亚洲影院色无极综合| 欧美视频在线看| 欧美成人免费一级人片100| 在线不卡a资源高清| 免费在线成人av| 亚洲精品一区在线观看| 亚洲欧美激情视频| 国产亚洲欧美中文| 麻豆精品传媒视频| 亚洲欧洲日本国产| 午夜宅男久久久| 欧美日韩国产综合视频在线| 一本色道久久加勒比88综合| 小黄鸭精品aⅴ导航网站入口| 国产乱码精品一区二区三区av| 91久久综合亚洲鲁鲁五月天| 亚洲伊人久久综合| 国内精品免费午夜毛片| 免费视频一区| 亚洲性感激情| 亚洲专区一二三| 黄色免费成人| 欧美三级电影一区| 欧美伊人影院| 亚洲免费精彩视频| 久久人人爽人人爽爽久久| 亚洲人永久免费| 国产九九精品视频| 欧美激情一区| 亚洲美女中出| 久久一区免费| 亚洲专区国产精品| 亚洲国产一区二区三区高清| 国产精品美女在线| 男女激情久久| 欧美一区二区三区电影在线观看| 欧美激情国产日韩精品一区18| 亚洲国产91| 国产女精品视频网站免费| 欧美精品二区三区四区免费看视频| 亚洲在线观看免费| 久久久久久夜| 中日韩美女免费视频网址在线观看 | 99国产一区二区三精品乱码| 亚洲视屏在线播放| 一色屋精品视频在线观看网站| 欧美视频中文字幕| 欧美成人午夜视频| 久久成人综合视频| 亚洲一区影音先锋| 一区二区不卡在线视频 午夜欧美不卡在 | 久久精品夜色噜噜亚洲aⅴ| 一区二区三区高清在线| 亚洲欧洲一级| 欧美国产日韩精品| 老司机免费视频一区二区三区 | 欧美人成在线| 久久亚洲国产成人| 久久精品卡一| 篠田优中文在线播放第一区| 久热精品在线视频| 欧美一区二区三区视频| 亚洲欧美日韩在线| 亚洲一区免费网站| 在线亚洲欧美专区二区| 国产一级揄自揄精品视频| 欧美性大战xxxxx久久久| 久久精品国产99国产精品| 香蕉国产精品偷在线观看不卡| 日韩系列欧美系列| 中文av字幕一区| 亚洲深夜激情| 亚洲欧美日韩在线高清直播| 亚洲自拍偷拍麻豆| 亚洲人成亚洲人成在线观看| 亚洲第一主播视频| 亚洲国产第一| 91久久久亚洲精品| 99精品福利视频| 亚洲一区二区免费| 香蕉久久久久久久av网站 | 欧美激情偷拍| 亚洲国产欧美一区二区三区丁香婷| 欧美a级片一区| 久久精彩免费视频| 久久手机精品视频| 欧美电影在线免费观看网站| 亚洲国产成人久久综合| 99国产欧美久久久精品| 亚洲在线观看免费| 久久久999国产| 欧美激情精品久久久| 国产精品免费久久久久久| 国产人成精品一区二区三| 国产综合色产在线精品| 亚洲国产精品激情在线观看| 99精品国产福利在线观看免费| 亚洲综合精品自拍| 蜜臀av在线播放一区二区三区 | 午夜视频一区二区| 久久性色av| 99精品国产热久久91蜜凸| 亚洲影视中文字幕| 美女视频黄a大片欧美| 欧美婷婷在线| 尤物九九久久国产精品的特点| 亚洲精品乱码久久久久久久久| 在线观看一区欧美| 精品电影在线观看| 一区二区三区久久精品| 久久久夜夜夜| 一区二区三区视频在线播放| 久久精品盗摄| 欧美色大人视频| 亚洲国产色一区| 欧美在线国产精品| 亚洲一级影院| 亚洲欧美激情视频在线观看一区二区三区| 久久精品国产久精国产思思| 亚洲激情视频在线观看| 欧美一区二区日韩| 欧美午夜免费影院| 亚洲欧洲日本一区二区三区| 久久精品久久99精品久久| 亚洲人人精品|