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

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>
            99成人免费视频| 久久精品一区二区三区中文字幕| 欧美亚洲一区二区三区| 亚洲乱码国产乱码精品精| 亚洲欧美日韩国产中文在线| 99视频一区二区| 另类综合日韩欧美亚洲| 久久久久久久综合色一本| 欧美日韩在线另类| 亚洲国产精品123| 狠狠色丁香婷婷综合| 亚洲欧美国产77777| 亚洲一区二区黄| 欧美激情视频网站| 欧美激情视频在线播放| 亚洲第一中文字幕| 久久九九热re6这里有精品| 欧美在线播放| 国产婷婷一区二区| 欧美专区在线| 久久久欧美精品| 国产亚洲福利一区| 欧美综合激情网| 久久精品最新地址| 韩国av一区二区三区| 欧美一区影院| 免费欧美日韩| 亚洲人成网站999久久久综合 | 久久久99免费视频| 国产精自产拍久久久久久| 亚洲一区日韩| 久久精品日韩欧美| 影音先锋欧美精品| 美国十次成人| 亚洲国产一区二区三区高清| 欧美暴力喷水在线| 日韩视频一区| 欧美一区二区在线| 黄色一区二区三区| 亚洲精品乱码久久久久| 亚洲香蕉伊综合在人在线视看| 欧美日精品一区视频| 亚洲一区二区免费看| 久久嫩草精品久久久精品一| 在线免费观看日本一区| 欧美国产日韩一二三区| 在线亚洲国产精品网站| 久久精品理论片| 亚洲欧洲日本专区| 欧美日韩小视频| 欧美淫片网站| 亚洲欧洲日本国产| 久久精品免视看| 亚洲精品国产无天堂网2021| 国产精品九色蝌蚪自拍| 久久久久久久网站| 亚洲日本免费电影| 久久精品国产免费| 99国产精品久久久久久久久久| 国产精品一区二区欧美| 久久一区欧美| 中文日韩欧美| 欧美激情在线播放| 欧美亚洲视频| 亚洲精品字幕| 国内精品久久久久影院优| 欧美日韩国产成人精品| 久久成人免费电影| 日韩午夜中文字幕| 欧美成人精品1314www| 午夜精品成人在线视频| 亚洲日本成人| 国模精品娜娜一二三区| 欧美午夜大胆人体| 欧美α欧美αv大片| 欧美一区1区三区3区公司| 99国产精品久久久久久久| 免费日韩成人| 久久精品一二三区| 小黄鸭精品密入口导航| 一二三区精品| 亚洲人成啪啪网站| 在线视频成人| 黄色精品一区二区| 国产日韩欧美一区| 国产精品草莓在线免费观看| 欧美激情四色| 免费成人黄色| 快she精品国产999| 久久久久久久波多野高潮日日| 亚洲永久字幕| 一区二区三区四区五区在线| 亚洲精品中文在线| 亚洲电影视频在线| 欧美黑人多人双交| 欧美a级在线| 美女主播一区| 免费欧美日韩国产三级电影| 久久久久久网| 久久久噜噜噜| 老司机67194精品线观看| 久久精品国产99国产精品| 久久不射电影网| 欧美一区二区网站| 欧美在线免费一级片| 久久精品1区| 久久久久久高潮国产精品视| 久久久久国产成人精品亚洲午夜| 午夜精品久久久久久| 欧美一级艳片视频免费观看| 午夜精品在线| 久久国产日韩| 免费亚洲网站| 欧美www视频| 亚洲黄一区二区三区| 亚洲精品国产品国语在线app| 亚洲日本精品国产第一区| 亚洲麻豆国产自偷在线| 在线性视频日韩欧美| 亚洲愉拍自拍另类高清精品| 午夜精品久久| 久久夜精品va视频免费观看| 欧美成人资源网| 欧美日韩三级| 国产日韩欧美91| 影音先锋日韩有码| 99国产精品久久久久老师 | 精品999成人| 亚洲第一页中文字幕| 9色国产精品| 亚洲免费视频观看| 久久久一区二区| 亚洲国产欧美在线| 中文av一区二区| 欧美一级久久久久久久大片| 久久视频国产精品免费视频在线| 欧美电影打屁股sp| 国产精品乱码一区二区三区| 国内成人自拍视频| 亚洲免费成人av| 久久成人一区| 91久久国产综合久久| 亚洲伊人观看| 免费视频最近日韩| 国产精品夜夜夜一区二区三区尤| 红桃视频国产精品| 一区二区三区欧美亚洲| 久久―日本道色综合久久| 亚洲精品日韩精品| 欧美在线91| 欧美日韩一区二区在线| 激情文学综合丁香| 亚洲一级二级| 亚洲福利小视频| 午夜一区二区三视频在线观看 | 国产精品中文字幕欧美| 亚洲国产精品国自产拍av秋霞| 亚洲欧美欧美一区二区三区| 欧美国产日韩一区二区三区| 亚洲欧美日韩在线综合| 欧美精品一区视频| 精品福利免费观看| 香港成人在线视频| 亚洲精品影院在线观看| 久久午夜视频| 国产亚洲永久域名| 西西人体一区二区| 日韩亚洲国产欧美| 美女亚洲精品| 国产亚洲欧美激情| 午夜日韩激情| 一本色道久久88综合亚洲精品ⅰ| 美乳少妇欧美精品| 激情久久影院| 久久久99爱| 亚欧成人精品| 国产精品视频久久久| 亚洲一区二区三区在线| 亚洲国产成人久久综合| 久久综合国产精品| 国内精品福利| 久久久久久久久综合| 午夜精品成人在线| 国产精品无人区| 欧美一区二区免费视频| 亚洲伊人一本大道中文字幕| 国产精品v欧美精品v日本精品动漫| 亚洲精品在线电影| 91久久精品一区| 欧美精品在线一区二区| aa日韩免费精品视频一| 亚洲日韩成人| 欧美日韩免费在线观看| 亚洲视频免费在线观看| 日韩午夜av在线| 欧美午夜视频网站| 午夜精品国产精品大乳美女| 亚洲综合日韩| 国产一区在线免费观看| 麻豆精品精华液|