学习: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. SeetaFaceQt:Qt多线程

    为什么要做多线程,说个最简单的道理就是我们不希望在软件处理数据的时候界面处于无法响应的假死状态.有些处理是灰常花时间的,如果把这样的处理放到主线程中执行,就会导致软件一条路走到底,要等到处理完才能接收 ...

  2. BZOJ 4033: [HAOI2015]树上染色

    题解: 树形DP 思路,考虑每条边的贡献,即这条边两边的黑点数量相乘+白点数量相乘再成边长 #include<iostream> #include<cstdio> #inclu ...

  3. 当切换用户时出现-bash-4.1$

    问题重现 [root@localhost ~]# su - yh -bash-4.1$ -bash-4.1$ -bash-4.1$ -bash-4.1$ -bash-4.1$ cd /home -ba ...

  4. linux tar/ tar.gz文件解压

    1.tar 压缩 tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg tar -czf jpg.tar.gz *.jpg   //将目录里所有jpg文件打包成 ...

  5. ADS1.2 调试问题

    最近一个程序需要用到ADS1.2这个软件,在使用过程中出现了如下问题: 1.由于以前用的是KEIL,所以没找到文件的工程,查资料才发现,这个工程文件打开的文件是MCP格式的文件: 2.调试的时候,没找 ...

  6. min25筛学习笔记

    min25筛简介:用来求积性函数F(x)前缀和的,复杂度O(n0.75/logn),大概能求n<=1010. 记一个数x的最小质因子为R(x),所以当x不为质数时,R(x)<=√x这是废话 ...

  7. POJ 1287 Networking【kruskal模板题】

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

  8. 基于JSP+Servlet新闻发布系统 源码

    开发环境: Windows操作系统开发工具: Eclipse+Jdk+Tomcat+MYSQL数据库 运行效果图:

  9. 吴裕雄--天生自然 PHP开发学习:表单验证

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title> ...

  10. build模式入门,build模式理解(转载)

    问:为何要用? 普通做法: 1.创建pojo public class Person { private String name; private int age; private double he ...