http://poj.org/problem?id=1113

夏令营讲课时的求凸包例题,据说是PKUSC2015的一道题

我WA两次错在四舍五入上了(=゚ω゚)ノ

#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double Pi = acos(-1);
const int N = 1003; struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
bool operator < (const Point &A) const {
return x == A.x ? y < A.y : x < A.x;
}
} a[N], tu[N];
int top = 1; Point operator + (Point a, Point b) {return Point(a.x + b.x, a.y + b.y);}
Point operator - (Point a, Point b) {return Point(a.x - b.x, a.y - b.y);}
Point operator * (Point a, double x) {return Point(a.x * x, a.y * x);}
Point operator / (Point a, double x) {return Point(a.x / x, a.y / x);} double Dot(Point a, Point b) {return a.x * b.x + a.y * b.y;}
double Cross(Point a, Point b) {return a.x * b.y - a.y * b.x;}
double sqr(double x) {return x * x;}
double dis(Point a, Point b) {return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));} int dcmp(double x) {return fabs(x) < 1e-8 ? 0 : (x < 0 ? -1 : 1);} void mktb(int n) {
tu[1] = a[1];
for(int i = 2; i <= n; ++i) {
while (top > 1 && dcmp(Cross(a[i] - tu[top], tu[top] - tu[top - 1])) <= 0) --top;
tu[++top] = a[i];
}
int k = top;
for(int i = n - 1; i >= 1; --i) {
while (top > k && dcmp(Cross(a[i] - tu[top], tu[top] - tu[top - 1])) <= 0) --top;
tu[++top] = a[i];
}
} int main() {
int n, l;
scanf("%d%d", &n, &l);
for(int i = 1; i <= n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y); sort(a + 1, a + n + 1); mktb(n); double ret = 2.0 * l * Pi;
for(int i = 1; i < top; ++i)
ret += dis(tu[i], tu[i + 1]); printf("%d\n", (int) (ret + 0.5));
return 0;
}

复习模板~

【POJ 1113】Wall的更多相关文章

  1. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  2. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  3. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  4. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  5. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

  6. BZOJ2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 126  Solved: 90[Submit][Sta ...

  7. BZOJ2296: 【POJ Challenge】随机种子

    2296: [POJ Challenge]随机种子 Time Limit: 1 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 114  Solv ...

  8. BZOJ2292: 【POJ Challenge 】永远挑战

    2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 513  Solved: 201[Submit][ ...

  9. 【POJ 1125】Stockbroker Grapevine

    id=1125">[POJ 1125]Stockbroker Grapevine 最短路 只是这题数据非常水. . 主要想大牛们试试南阳OJ同题 链接例如以下: http://acm. ...

随机推荐

  1. 分享——张南《从Desktop到Mobile的自动化测试实践》

    张南在top100summit(14年)上分享了google从Desktop到Mobile的自动化测试实践,这里分享一下 案例简述 随着每年移动用户量的增长,移动网络速度以及覆盖力的增强,移动设备逐年 ...

  2. android:TableLayout表格布局详解

    1.TableLayout简介2.TableLayout行列数的确定3.TableLayout可设置的属性详解4.一个包含4个TableLayout布局的实例及效果图一.Tablelayout简介  ...

  3. ipone5 无法安装ipa软件

    iphone5s软件无法安装解决方法一,点击设置 - 通用 - 访问限制,先关闭“安装应用程序”选项,再打开,把后台应用程序刷新也关了,测试. iphone5s软件无法安装解决方法二,点击设置 - 通 ...

  4. DINIC网络流+当前弧优化

    DINIC网络流+当前弧优化 const inf=; type rec=record s,e,w,next:longint; end; var b,bb,d,q,tb:..] of longint; ...

  5. 常见HTTP状态基本解释

    本文摘自互联网,但是忘记了具体网址,请见谅 在网站建设的实际应用中,容易出现很多小小的失误,就像mysql当初优化不到位,影响整体网站的浏览效果一样,其实,网站的常规http状态码的表现也是一样,Go ...

  6. 使用PHP获取根域名的方法!

    /** * 取得根域名 * @param type $domain 域名 * @return string 返回根域名 */ function GetUrlToDomain($domain) { $r ...

  7. Native code on Windows Phone 8(转)

    Windows Phone 8 introduces the ability to use native code to implement Windows Phone. In this sectio ...

  8. NOI2018准备 Day10

    效率低低低低低非常低!!!!!!!!!!!!!!!!!!!!!!! noi3.3 布尔表达式 做了2个晚上做不出来... 不过今晚上A了一道很水的找规律题

  9. md5的C++实现

    一.原理 前一阵子,想知道md5的原理查了一下资料,说得基本都一样,最后让我看懂的是这两个链接: http://blog.csdn.net/qf_study/article/details/26309 ...

  10. React Native中设计主题机制

    昨天和同事讨论组件隔离性的时候讨论到关于默认样式的问题:很多情况下我们希望能够把组件设计为通用的,然后在具体项目中给他们指定一些通用的样式,譬如:背景颜色.默认字体等等.这听起来在CSS下运作起来就很 ...