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

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>
            亚洲人成毛片在线播放| 亚洲男女毛片无遮挡| 久久久夜夜夜| 伊人精品在线| 亚洲国产免费看| 欧美精品手机在线| 亚洲在线视频| 亚洲欧美国产日韩中文字幕| 国产欧美日本一区视频| 久久九九久精品国产免费直播| 久久aⅴ国产欧美74aaa| 尤物在线精品| 亚洲三级视频| 国产欧美一区二区白浆黑人| 久久久久国产一区二区| 久久综合一区二区| 中文亚洲欧美| 欧美在线欧美在线| 亚洲日韩成人| 亚洲视频一二三| 亚洲成色999久久网站| 91久久久久久| 国产精自产拍久久久久久| 久久影音先锋| 欧美三级黄美女| 久久资源在线| 国产精品s色| 欧美99久久| 国产精品老女人精品视频| 蜜乳av另类精品一区二区| 欧美日韩国产123区| 久久免费观看视频| 欧美日韩在线播放一区| 久久久久久伊人| 欧美日韩国产综合视频在线| 久久久国际精品| 欧美三级韩国三级日本三斤| 久久午夜电影| 国产精品自在线| 亚洲精品国久久99热| 国产一区二区三区日韩欧美| 亚洲精品日韩久久| 亚洲国产黄色| 欧美一区二区精品| 亚洲一区网站| 欧美二区在线播放| 另类天堂视频在线观看| 国产精品爽爽ⅴa在线观看| 亚洲国产精品电影| 精品白丝av| 午夜在线不卡| 午夜天堂精品久久久久| 欧美精品在线一区二区| 蜜臀av一级做a爰片久久| 国产精品一区二区三区久久久| 亚洲精品视频在线观看网站| 亚洲风情亚aⅴ在线发布| 欧美伊久线香蕉线新在线| 午夜激情一区| 欧美性猛片xxxx免费看久爱| 亚洲精品免费一二三区| 亚洲日本中文| 欧美电影专区| 亚洲国产精品日韩| 91久久亚洲| 欧美成人a视频| 欧美激情视频一区二区三区免费| 在线电影欧美日韩一区二区私密| 欧美综合激情网| 久久久亚洲欧洲日产国码αv | 欧美激情一区二区三级高清视频| 国产日韩综合| 欧美中文字幕视频在线观看| 久久久亚洲午夜电影| 国产亚洲精品一区二区| 欧美一乱一性一交一视频| 欧美一区二视频在线免费观看| 国产精品电影观看| 亚洲香蕉网站| 久久久精品2019中文字幕神马| 国产一区二区三区在线观看精品| 午夜精品视频| 蜜桃av一区二区三区| 亚洲人成绝费网站色www| 欧美黄色日本| 一卡二卡3卡四卡高清精品视频| 亚洲在线观看免费| 国产女人aaa级久久久级| 久久成人免费电影| 亚洲国产成人av| 亚洲一区二区三区精品在线观看 | 麻豆精品视频在线| 亚洲激情偷拍| 亚洲欧美日韩中文播放| 国产一区二区精品丝袜| 欧美成人综合在线| 亚洲午夜久久久久久久久电影院 | 日韩一二三区视频| 久久精品成人一区二区三区| 极品裸体白嫩激情啪啪国产精品| 欧美.日韩.国产.一区.二区| 一区二区黄色| 免费国产一区二区| 亚洲免费视频一区二区| 黄色亚洲免费| 国产精品xnxxcom| 久久精品国产精品亚洲| 亚洲日韩欧美视频一区| 久久精品五月婷婷| 亚洲精品国产无天堂网2021| 国产农村妇女精品一二区| 免费一级欧美片在线播放| 在线一区日本视频| 欧美激情精品久久久久久大尺度 | 午夜日本精品| 最近中文字幕日韩精品| 国产精品日韩精品欧美在线| 欧美成人资源网| 久久爱www.| 亚洲午夜羞羞片| 亚洲片在线资源| 老司机精品视频一区二区三区| 亚洲尤物视频在线| 亚洲伦理在线免费看| 国产一区二区三区直播精品电影| 欧美国产日产韩国视频| 久久精品视频导航| 亚洲欧美在线一区二区| 一区二区三区日韩| 亚洲精品久久久久久久久| 美女视频一区免费观看| 久久国产精品毛片| 性欧美激情精品| 亚洲资源av| 亚洲亚洲精品三区日韩精品在线视频 | 日韩亚洲欧美成人一区| 欧美国产欧美综合| 免费精品视频| 欧美www视频| 免费一级欧美在线大片| 久久色在线播放| 久久久美女艺术照精彩视频福利播放| 亚洲综合首页| 亚洲女人天堂成人av在线| 亚洲图片在线| 亚洲自拍偷拍网址| 亚洲欧美日韩精品久久| 亚洲欧美日本日韩| 午夜精品久久久久| 久久精品国产99国产精品| 欧美在线播放一区| 久久都是精品| 久久亚洲精选| 欧美成人免费网| 亚洲电影在线播放| 亚洲毛片在线| 亚洲图片欧美日产| 午夜精品影院| 久久亚洲欧美| 欧美高清在线观看| 欧美视频二区36p| 国产美女一区二区| 国产日韩欧美在线看| 红桃视频亚洲| 亚洲美女在线国产| 亚洲午夜久久久久久久久电影院| 亚洲女人天堂av| 久久久久久夜精品精品免费| 牛牛精品成人免费视频| 亚洲国内在线| 亚洲综合欧美| 久久免费视频网| 欧美日韩一卡二卡| 国产婷婷成人久久av免费高清| 韩国精品一区二区三区| 亚洲九九九在线观看| 亚洲一二三区在线观看| 久久久www成人免费毛片麻豆| 麻豆精品一区二区av白丝在线| 最新日韩精品| 欧美亚洲视频| 欧美激情一区二区在线| 国产精品亚洲精品| 91久久国产精品91久久性色| 亚洲无线视频| 久久综合99re88久久爱| 亚洲美女诱惑| 久久免费视频一区| 国产精品国产三级欧美二区 | 欧美人牲a欧美精品| 国产欧美一区二区白浆黑人| 最新国产拍偷乱拍精品 | 玉米视频成人免费看| 一本色道**综合亚洲精品蜜桃冫 | 亚洲精品综合久久中文字幕| 午夜宅男欧美| 最新国产精品拍自在线播放| 欧美在线精品免播放器视频| 欧美日韩国产成人| 在线播放中文一区|