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

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ù)夾角,求弧長,而總弧長就是周長。
 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; // 左右鏈必須分開處理,點(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 閱讀(760) 評論(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>
            亚洲精品日韩一| 日韩一区二区精品| 久久久精品日韩| 免费成人你懂的| 亚洲区一区二区三区| 欧美日韩123| 亚洲天堂av图片| 久久漫画官网| 日韩午夜av在线| 国产精品试看| 久久久人成影片一区二区三区观看 | 亚洲综合国产| 久久综合九色99| 亚洲最快最全在线视频| 国产欧美日韩免费看aⅴ视频| 久久久久国内| 99综合在线| 久久一综合视频| 正在播放欧美一区| 国产偷国产偷精品高清尤物| 免费不卡视频| 欧美亚洲日本网站| 欧美国产日韩一区二区三区| 亚洲欧美国产77777| 精品动漫3d一区二区三区免费版| 欧美日韩18| 久久久久在线观看| 亚洲影院免费观看| 亚洲国产精品一区二区www在线| 宅男精品视频| 亚洲人成亚洲人成在线观看| 国产精自产拍久久久久久蜜| 欧美激情一区二区三区在线视频观看| 亚洲一区精品视频| 亚洲精品国产精品乱码不99 | 一本大道久久a久久综合婷婷 | 亚洲欧美日韩天堂| 亚洲人成在线观看一区二区| 久久久精品免费视频| 一区二区三区四区在线| 136国产福利精品导航网址| 国产精品久久久久久久久免费| 老司机67194精品线观看| 午夜精品国产精品大乳美女| 日韩视频精品| 欧美激情精品久久久六区热门| 久久人体大胆视频| 欧美一级成年大片在线观看| 一区二区三区精品视频在线观看| 亚洲第一免费播放区| 国产视频久久| 国产裸体写真av一区二区| 欧美日韩一区二区在线视频| 欧美大片免费| 久久综合色88| 久久久一区二区三区| 欧美一区二区三区精品电影| 午夜精品一区二区三区四区 | 亚洲欧美另类中文字幕| 夜久久久久久| 日韩一区二区高清| 99国产精品久久久| 一区二区三区四区蜜桃| 99re6热只有精品免费观看| 亚洲高清av| 亚洲国产成人高清精品| 在线免费观看成人网| 精品91在线| 在线免费不卡视频| 亚洲高清免费在线| 亚洲精品视频一区二区三区| 亚洲精品麻豆| 亚洲美女在线视频| 这里只有精品在线播放| 亚洲一区免费在线观看| 亚洲一区欧美二区| 香蕉国产精品偷在线观看不卡| 亚洲欧美一区二区激情| 午夜久久电影网| 久久精品国产清自在天天线| 久久久国产一区二区三区| 久久先锋资源| 亚洲第一综合天堂另类专| 亚洲精品人人| 亚洲尤物视频网| 久久激情五月激情| 欧美电影美腿模特1979在线看| 欧美高清视频免费观看| 欧美日韩一区免费| 国产精品资源在线观看| 狠狠色狠狠色综合日日91app| 黄页网站一区| 一本一本a久久| 欧美一级久久久| 欧美成人dvd在线视频| 亚洲日本中文字幕免费在线不卡| 亚洲天堂激情| 久久久久久一区二区| 欧美精品在线视频| 国产精品视频内| 亚洲黄色大片| 亚洲欧美中日韩| 免费看亚洲片| 亚洲美女色禁图| 欧美一区二区高清在线观看| 欧美成人免费小视频| 国产精品久久久久9999吃药| 激情欧美一区二区三区在线观看| 亚洲理论电影网| 久久精品天堂| 亚洲激情在线激情| 欧美亚洲色图校园春色| 欧美激情国产日韩精品一区18| 国产精品ⅴa在线观看h| 国内在线观看一区二区三区| 夜夜狂射影院欧美极品| 久久久国产精品亚洲一区| 亚洲精品欧洲| 久久精品亚洲热| 国产精品vvv| 亚洲国产精品精华液2区45| 亚洲欧美在线网| 91久久精品国产| 久久精品盗摄| 国产精品久久看| 亚洲精选在线观看| 久久综合999| 亚洲欧美国产视频| 欧美精品一区二区视频| 在线不卡中文字幕| 欧美一区二区精品| 夜夜精品视频| 欧美精品1区2区| 亚洲国产精品va在线看黑人动漫| 午夜日韩在线| 在线午夜精品| 欧美看片网站| 亚洲精品午夜精品| 美日韩免费视频| 先锋影音网一区二区| 国产精品久久久久永久免费观看| 亚洲精品在线视频| 欧美成ee人免费视频| 久久久国产午夜精品| 国产亚洲欧美一级| 性色av一区二区三区在线观看| 9i看片成人免费高清| 欧美美女福利视频| 日韩视频一区二区三区在线播放免费观看| 麻豆精品在线播放| 久久av最新网址| 国产偷久久久精品专区| 欧美一级久久久久久久大片| 亚洲天堂成人在线观看| 国产精品v亚洲精品v日韩精品 | 欧美国产欧美亚州国产日韩mv天天看完整| 午夜国产精品视频| 国产精品三级视频| 新67194成人永久网站| 亚洲一区亚洲二区| 国产精品热久久久久夜色精品三区 | 久久综合久久久| 久久成人免费电影| 好男人免费精品视频| 久久午夜电影网| 久久综合久久综合这里只有精品| 亚洲福利在线视频| 亚洲国产美女精品久久久久∴| 欧美va亚洲va日韩∨a综合色| 91久久精品美女高潮| 亚洲国产清纯| 欧美日韩一卡| 久久国产精品免费一区| 午夜视频在线观看一区二区三区| 国产揄拍国内精品对白| 欧美fxxxxxx另类| 欧美大片在线观看| 亚洲一区中文字幕在线观看| 亚洲一区二区黄| 国内偷自视频区视频综合| 免费美女久久99| 欧美区一区二| 午夜精品理论片| 久久av老司机精品网站导航| 伊人久久综合97精品| 亚洲激情一区二区| 国产精品乱人伦中文| 久久一区中文字幕| 欧美精品高清视频| 亚洲欧美亚洲| 麻豆av一区二区三区久久| 亚洲视频大全| 久久精品成人欧美大片古装| 亚洲精品在线二区| 亚洲图片激情小说| 亚洲国产片色| 午夜精品短视频| 亚洲美女av电影| 欧美一区二区精品| 日韩视频在线一区二区三区|