学习: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. [转]Linux命令行上传文件到 百度网盘 bypy

    安装软件工具: apt-get install python-pip pip install requests pip install bypy 授权登陆: 执行 bypy info,显示下边信息,根 ...

  2. 使用 prototype 定义方法和属性

    除了可以在类的构造器方法中定义方法和属性外,也可以使用 prototype 定义方法和属性.每个类都有这个属性,该属性是一个静态属性,因此无需实例化,只需使用类引用该属性即可. 1.1 使用 prot ...

  3. Shell脚本exit用法与区别

    在Shell脚本中,往往会遇到一些判断类型为某个值不符合预期值的时候就退出主脚本/当前脚本/当前函数,那么Exit与return的用法与区别是什么呢? 下面先使用Exit举个简单例子,脚本内容如下 # ...

  4. Cracking Digital VLSI Verification Interview 第二章

    Computer Architecture 对Cracking Digital VLSI Verification Interview:Interview Success这本书的汉化,最新更新请关注微 ...

  5. logrus日志框架

    目录 logrus介绍 logrus配置 日志打印 HOOK机制 Gin日志 Fatal处理 线程安全 logrus介绍 golang标准库的日志框架非常简单,仅仅提供了print,panic和fat ...

  6. winform使用钩子限制windows热键

    新增类KeybordHookProc using System; using System.Collections.Generic; using System.Diagnostics; using S ...

  7. 编写注册表.reg文件

    Windows 中的注册表文件( system.dat 和 user.dat )是 Windows 的核心数据库,因此,对 Windows 来说是非常重要的. 通过修改注册表文件中的数据,可以达到优化 ...

  8. PAT-树-DFS-BFS相关问题解决方案整理

    如何建树? 二叉树-建树-方式一 dfs使用root左右指针建立树节点关系,返回根节点root 二叉树-建树-方式二 dfs使用二维数组,int nds[n][2],如:nds[i][0]表示i节点的 ...

  9. 关于 tf.image.crop_and_resize的使用

    https://blog.csdn.net/m0_38024332/article/details/81779544 关于 tf.image.crop_and_resize 的使用  最近在学习fas ...

  10. LeetCode——324. 摆动排序 II

    给定一个无序的数组 nums,将它重新排列成 nums[0] < nums[1] > nums[2] < nums[3]... 的顺序. 示例 1: 输入: nums = [1, 5 ...