链接

多校的最后一场,当时没看懂题意,看题目还以为是概率问题就没深看。

官方题解

对于他说的第一种,考虑长为L的线段 概率为2L/(pi*d), 可以理解,下面的就不知道在说啥了。。

按我初始的想法想要枚举角度,根据凸包的高度差得出概率,不过有一种更简便的方式,就是题解中的求出凸包的周长,这种方式我的理解为,凸包中的一条线段穿过直线的概率就跟上面所说的线段一样2L/(pi*d),不过因为他是个多边形,有进就肯定有出,所以穿过一条线段就相当于穿过两条,整体来说就是/2...不知道这种理解方式对不对

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 111
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct point
{
double x,y;
point(double x=,double y = ):x(x),y(y){}
}p[N],ch[N];
typedef point pointt;
point operator -(point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
double cross(point a,point b)
{
return a.x*b.y-a.y*b.x;
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
double mul(point p0,point p1,point p2)
{
return cross(p1-p0,p2-p0);
}
double dis(point a)
{
return sqrt(a.x*a.x+a.y*a.y);
}
bool cmp(point a,point b)
{
if(dcmp(mul(p[],a,b))==)
return dis(a-p[])<dis(b-p[]);
else
return dcmp(mul(p[],a,b))>;
}
int Graham(int n)
{
int i,k = ,top;
point tmp;
for(i = ; i < n; i++)
{
if(p[i].y<p[k].y||(p[i].y==p[k].y&&p[i].x<p[k].x))
k = i;
}
if(k!=)
{
tmp = p[];
p[] = p[k];
p[k] = tmp;
}
sort(p+,p+n,cmp);
ch[] = p[];
ch[] = p[];
top = ;
for(i = ; i < n ; i++)
{
while(top>&&dcmp(mul(ch[top-],ch[top],p[i]))<)
top--;
top++;
ch[top] = p[i];
}
return top;
} int main()
{
int t,i,n,d;
int kk = ;
cin>>t;
while(t--)
{
scanf("%d%d",&n,&d);
for(i = ; i < n; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
int m = Graham(n);
ch[m+] = ch[];
double ans = ;
for(i = ; i <= m ; i++)
ans += dis(ch[i]-ch[i+]);
printf("Case #%d: %.4f\n",++kk,ans/(pi*d));
}
return ;
}

hdu4987A simple probability problem.(凸包)的更多相关文章

  1. HDU 4978 A simple probability problem

    A simple probability problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  2. BNU 28887——A Simple Tree Problem——————【将多子树转化成线段树+区间更新】

    A Simple Tree Problem Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on ZJU. O ...

  3. BZOJ 3489: A simple rmq problem

    3489: A simple rmq problem Time Limit: 40 Sec  Memory Limit: 600 MBSubmit: 1594  Solved: 520[Submit] ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. 【BZOJ2318】Spoj4060 game with probability Problem 概率

    [BZOJ2318]Spoj4060 game with probability Problem Description Alice和Bob在玩一个游戏.有n个石子在这里,Alice和Bob轮流投掷硬 ...

  6. hdu4976 A simple greedy problem. (贪心+DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=4976 2014 Multi-University Training Contest 10 1006 A simp ...

  7. hdu 1757 A Simple Math Problem (乘法矩阵)

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. HDU1757 A Simple Math Problem 矩阵快速幂

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  9. hdu------(1757)A Simple Math Problem(简单矩阵快速幂)

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

随机推荐

  1. A quick renice command rescheduled the upgrade to a lower priority and I was back to surfing in no time.

    https://www.nixtutor.com/linux/changing-priority-on-linux-processes/ Changing Priority on Linux Proc ...

  2. situations where MyISAM will be faster than InnoDB

    http://www.tocker.ca/categories/myisam Converting MyISAM to InnoDB and a lesson on variance I'm abou ...

  3. LINUX VI 常用命令

    vi 打开或新建 vi filename 打开或新建文件 并将光标置于第一行首 光标 )  光标移至句尾 (  光标移至句首 屏幕翻滚类命令 Ctrl+u 向文件首翻半屏 Ctrl+d 向文件尾翻半屏 ...

  4. 【五子棋AI循序渐进】关于VCT,VCF的思考和核心代码

    前面几篇发布了一些有关五子棋的基本算法,其中有一些BUG也有很多值得再次思考的问题,在框架和效果上基本达到了一个简单的AI的水平,当然,我也是初学并没有掌握太多的高级技术.对于这个程序现在还在优化当中 ...

  5. 显示HTML文本

    + (NSAttributedString*)getAttributedStringFromHtmlString:(NSString*)htmlString{ return [[NSAttribute ...

  6. Class类

    package com.imooc.reflect; public class ClassDemo1 { public static void main(String[] args) { //Foo的 ...

  7. SQL Server 索引中include的魅力(具有包含性列的索引)

    2010-01-11 20:44 by 听风吹雨, 22580 阅读, 24 评论, 收藏, 编辑 开文之前首先要讲讲几个概念 [覆盖查询] 当索引包含查询引用的所有列时,它通常称为“覆盖查询”. [ ...

  8. Python之路-python(面向对象进阶)

    一.面向对象高级语法部分 1.静态方法.类方法.属性方法 2.类的特殊方法 3.反射 二.异常处理 三.Socket开发基础 一.面向对象高级语法部分 静态方法(@staticmethod) 定义:只 ...

  9. 原生js快速渲染dom节点

    function renderDom(str){ var _div = document.createElement('div'); _div.innerHTML = str; var dom_tem ...

  10. [CrunchBang]tint2默认设置

    #--------------------------------------------- # TINT2 CONFIG FILE #-------------------------------- ...