学习:https://blog.csdn.net/qq_21334057/article/details/99550805

题意:从nn个点中选择kk个点构成多边形,问期望面积。

题解:如果能够确定两个点,那么可以从这两个点之间选择k−2个点来构成一个k边形。所以可以枚举两个点,计算这两个点被选入构成凸包的概率和对凸包贡献的面积。

#include <bits/stdc++.h>
#define fopi freopen("in.txt", "r", stdin)
#define fopo freopen("out.txt", "w", stdout)
using namespace std;
typedef long long LL;
typedef long double ld;
const int maxn = + ; struct Point {
ld x, y;
}a[maxn]; ld C[maxn][maxn]; void getC(int n) {
C[][] = ;
for (int i = ; i <= n; i++) {
C[i][] = ;
for (int j = ; j <= i; j++)
C[i][j] = C[i-][j] + C[i-][j-];
}
} ld Cross(Point a, Point b) {
return a.x*b.y - a.y*b.x;
} int n, k;
int main() {
ios::sync_with_stdio(false); cin >> n >> k;
getC(n); for (int i = ; i <= n; i++)
cin >> a[i].x >> a[i].y; ld ans = ;
for (int i = ; i <= n; i++)
for (int j = k-; j <= n-; j++) {
int t = i+j;
if (t > n) t -= n;
ans += Cross(a[i], a[t]) * C[j-][k-] / C[n][k];
} printf("%.7Lf\n", ans/);
}

NAIPC 2019 A - Piece of Cake(凸包计算)的更多相关文章

  1. A - Piece of Cake Kattis - pieceofcake (数学)

    题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...

  2. Win8 Metro(C#)数字图像处理--2.74图像凸包计算

    原文:Win8 Metro(C#)数字图像处理--2.74图像凸包计算 /// <summary> /// Convex Hull compute. /// </summary> ...

  3. ZOJ 3537 Cake(凸包判定+区间DP)

    Cake Time Limit: 1 Second Memory Limit: 32768 KB You want to hold a party. Here's a polygon-shaped c ...

  4. ZOJ - 3537 Cake (凸包+区间DP+最优三角剖分)

    Description You want to hold a party. Here's a polygon-shaped cake on the table. You'd like to cut t ...

  5. UVa 109 - SCUD Busters(凸包计算)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  6. 2019.02.21 bzoj2829: 信用卡凸包(凸包)

    传送门 题意:给nnn个A∗BA*BA∗B的矩形,其中每个矩形的四个角被改造成了半径为rrr的四分之一 圆,问这些矩形的凸包周长. 思路:考虑求出圆心的凸包周长然后加上一个整圆的周长,证明很简单,略掉 ...

  7. Jarvis OJ A Piece Of Cake

    看图片的隐写术自闭,本来想看一看jarvisoj 的basic放松一下心情,结果一道题就做了一晚上qwq 首先看到这道题的时候想到的是凯撒密码(这其实是Google之后才知道这个名字的)枚举了26种位 ...

  8. SCUT - 249 - A piece of Cake - 组合数学

    https://scut.online/contest/25/I 由结论:d维物体切n刀分成的部分=sum(C(n,0)~C(n,d)),直接算就行了.

  9. CF171C 【A Piece of Cake】

    遵从题意枚举暴力读人n,再求出$\sum^n_1a[i]*i$然后输出答案,(记得开个long long以免炸掉)以下是代码: #include<bits/stdc++.h> using ...

随机推荐

  1. Python csv文件操作

    一.open文件打开和with open as 文件打开的区别 file= open("test.txt","r") try: for line in file ...

  2. IDEA--安装

    1:下载IDEA 官网:http://www.jetbrains.com/idea/download/#section=windows(选择下载.zip) 2:解压 3:破解: 1)在C:\Windo ...

  3. 如何写出高质量的Python代码--做好优化--改进算法点滴做起

    小伙伴你的程序还是停留在糊墙吗?优化代码可以显示程序员的素质欧! 普及一下基础了欧: 一层for简写:y = [1,2,3,4,5,6],[(i*2) for i in y ]       会输出  ...

  4. MySQL视图和事务

    视图的操作                                                                                                ...

  5. Java 静态static关键字,main函数,对象的初始化过程,对象调用成员,单例模式的设计,静态代码块(6)

    Java 静态static关键字,静态代码块详情参考:static的使用原理讲解http://www.cnblogs.com/itcqx/p/5519464.html main函数: java Mai ...

  6. POJ 1287 Networking【kruskal模板题】

    传送门:http://poj.org/problem?id=1287 题意:给出n个点 m条边 ,求最小生成树的权 思路:最小生树的模板题,直接跑一遍kruskal即可 代码: #include< ...

  7. Go 验证是否字符串包含中文

    发现一个验证字符串是否包含中文滴时候,一个比正则更好使滴方法,而且是golang 自带滴验证. 不需要自己写正则验证,代码如下: package main import ( "fmt&quo ...

  8. 题解 LOJ-6485 【LJJ学二项式定理】

    题目 由于看到正解的单位根反演过于复杂 (也就是看不懂) 所以自己构造了一个算法,理论上这个算法应该还有成长的空间(可以变得普适性更强) 不知道和单位根反演有没有一样,就发表出来了 反正转载前记得要联 ...

  9. tensorflow模型

    图像模型 YOLOv3 , 地址 https://pjreddie.com/darknet/yolo/ vgg , 参考 https://github.com/tensorflow/models/bl ...

  10. springCloud 常用组件总结

    本文浅谈只是对我自己初期认识这spring cloud的一个笔记. 微服务是一种架构风格和一种应对业务的架构策略.实现这种的技术方式很多.本文主要说spring cloud. spring cloud ...