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

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>
            亚洲高清视频在线观看| 亚洲激情社区| 亚洲一区二区精品视频| 亚洲电影在线看| 欧美www在线| 亚洲人成在线播放网站岛国| 欧美电影免费观看| 久久综合色天天久久综合图片| 亚洲国产导航| 亚洲国产一区视频| 欧美日韩综合视频网址| 亚洲免费在线视频| 欧美一区二区在线免费观看| 国际精品欧美精品| 欧美激情视频网站| 欧美日本高清视频| 亚洲欧美成人在线| 欧美一级网站| 99视频超级精品| 亚洲欧美国产日韩中文字幕| 黄色成人av| 亚洲精品视频中文字幕| 国产日韩欧美91| 亚洲高清成人| 国产欧美亚洲精品| 欧美大片在线观看一区| 国产精品国产三级国产aⅴ浪潮 | 在线日韩欧美| 日韩视频久久| 在线不卡视频| 99精品久久免费看蜜臀剧情介绍| 国产欧美一区二区三区久久| 欧美成人免费视频| 国产精品sss| 欧美大色视频| 国产日韩精品在线播放| 亚洲精品你懂的| 国产精品亚洲综合色区韩国| 欧美激情女人20p| 国产亚洲成av人片在线观看桃| 亚洲国产91精品在线观看| 国产精品视频一| 亚洲人成网站777色婷婷| 国产亚洲免费的视频看| 99国产一区二区三精品乱码| 精品电影在线观看| 亚洲欧美日韩一区| 亚洲欧美日产图| 欧美精品国产精品日韩精品| 久久婷婷一区| 国产美女一区| 亚洲一区二区三区欧美| 日韩午夜在线观看视频| 免费不卡在线视频| 欧美1区免费| 国模精品一区二区三区色天香| 一本到12不卡视频在线dvd| 亚洲国产美女| 久久久蜜桃一区二区人| 久久久国产亚洲精品| 欧美色区777第一页| 亚洲精品欧洲精品| 亚洲日本理论电影| 欧美大胆人体视频| 欧美激情一区二区三区| 在线精品一区| 久久久综合网站| 欧美va亚洲va日韩∨a综合色| 狠狠狠色丁香婷婷综合激情| 午夜日韩在线| 久久久www| 尤物网精品视频| 久久综合给合久久狠狠色| 麻豆久久婷婷| 在线观看欧美亚洲| 免费成人激情视频| 亚洲国产日韩欧美在线动漫| 亚洲精品一区中文| 欧美日韩视频在线第一区| 亚洲精品国产精品国产自| 中日韩在线视频| 国产精品美女久久久浪潮软件| 中文一区在线| 欧美在线三级| 精久久久久久| 欧美成人一区二区在线| 亚洲欧洲三级电影| 亚洲在线视频| 狠狠综合久久av一区二区小说| 久久在线视频在线| 亚洲伦理网站| 久久久精品网| 亚洲免费观看高清完整版在线观看熊 | 欧美一区二区在线免费播放| 国产色视频一区| 麻豆国产精品va在线观看不卡| 亚洲人久久久| 久久国产精品久久精品国产| 在线电影欧美日韩一区二区私密| 欧美激情视频一区二区三区不卡| 一本色道精品久久一区二区三区| 久久大逼视频| 日韩一本二本av| 国产欧美1区2区3区| 久久这里有精品视频| 一区二区三区不卡视频在线观看 | 99视频热这里只有精品免费| 国产精品视频精品| 欧美成人乱码一区二区三区| 中日韩午夜理伦电影免费| 久久综合色一综合色88| 夜夜嗨网站十八久久| 国产久一道中文一区| 欧美不卡视频一区发布| 亚洲免费在线视频| 亚洲国产小视频| 久久激情视频| 亚洲无线观看| 亚洲国产日韩一区二区| 国产欧美日韩在线视频| 欧美久久久久免费| 久久精品首页| 亚洲调教视频在线观看| 亚洲二区视频| 久久国产视频网| 亚洲综合日韩在线| 亚洲日本成人女熟在线观看| 国外精品视频| 国产乱人伦精品一区二区 | 久久精品国产亚洲高清剧情介绍| 亚洲日本欧美| 亚洲成色精品| 老司机一区二区三区| 欧美在线视频全部完| 亚洲一二三级电影| 日韩一级黄色av| 亚洲黄色天堂| 一区二区亚洲精品国产| 国产日韩精品久久久| 国产精品视频免费观看| 欧美午夜性色大片在线观看| 欧美成人精精品一区二区频| 久久尤物视频| 久久精品九九| 久久国产精品亚洲va麻豆| 亚洲欧美在线磁力| 性视频1819p久久| 日韩视频不卡| 一区二区三区黄色| 一本久道久久综合狠狠爱| 亚洲伦理在线| 一区二区三区国产精华| 一区二区电影免费观看| 99国产精品久久久久久久| 亚洲精品视频一区| 宅男精品视频| 久久av一区二区三区漫画| 久久久国产精品一区| 久久久久一区| 欧美高清一区| 欧美婷婷六月丁香综合色| 国产精品日韩精品欧美在线| 国产欧美一区二区三区视频 | 欧美久久电影| 欧美三区免费完整视频在线观看| 欧美日韩亚洲天堂| 国产女主播一区| 亚洲高清视频在线观看| 亚洲人在线视频| 亚洲欧美成人综合| 久久久精品网| 亚洲三级国产| 亚洲综合首页| 免费成人黄色av| 国产精品成人一区二区三区夜夜夜| 国产精品免费在线| 在线精品一区二区| 一本久道综合久久精品| 亚洲欧美在线x视频| 久久日韩粉嫩一区二区三区| 欧美成人中文| 亚洲综合999| 久久米奇亚洲| 国产精品久久波多野结衣| 国内精品美女在线观看| 91久久综合| 久久国产精品网站| 亚洲激情专区| 欧美在线视频一区| 欧美激情性爽国产精品17p| 国产精品午夜国产小视频| 亚洲人体一区| 久久亚洲国产成人| 亚洲视屏一区| 麻豆成人91精品二区三区| 国产精品夜夜夜| 日韩视频中午一区| 久久综合久久久久88| 亚洲午夜电影网| 欧美肥婆bbw|