题意:

有一个不保证凸的多边形,让你滚一圈,计算某点滚出的轨迹多长。

题解:

求出凸包后,以每个点为转轴,转轴到定点的距离为半径,用余弦定理计算圆心角,计算弧长。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
int t,case1=;
cin>>t;
while(t--)
{
case1++;
int n;
cin>>n;
int x[],y[];//贮存坐标
for(int i=;i<=n;i++)
{
cin>>x[i]>>y[i];
}
int xx,yy;
cin>>xx>>yy;
double dis[];
for(int i=;i<=n;i++)
{
dis[i]=(x[i]-xx)*(x[i]-xx)+(y[i]-yy)*(y[i]-yy);
//cout<<dis[i]<<endl;
}
//cout<<endl;
double ankle[];
for(int i=;i<=n;i++)
{
double t1,t2,t3;
if(xx==x[i]&&yy==y[i])
continue;
if(i==)
{
t1=sqrt((x[]-x[])*(x[]-x[])+(y[]-y[])*(y[]-y[]));
t2=sqrt((x[n]-x[])*(x[n]-x[])+(y[n]-y[])*(y[n]-y[]));
t3=sqrt((x[n]-x[])*(x[n]-x[])+(y[n]-y[])*(y[n]-y[]));
}
else if(i==n)
{
t1=sqrt((x[n]-x[])*(x[n]-x[])+(y[n]-y[])*(y[n]-y[]));
t2=sqrt((x[n]-x[n-])*(x[n]-x[n-])+(y[n]-y[n-])*(y[n]-y[n-]));
t3=sqrt((x[n-]-x[])*(x[n-]-x[])+(y[n-]-y[])*(y[n-]-y[]));
}
else
{
t1=sqrt((x[i+]-x[i])*(x[i+]-x[i])+(y[i+]-y[i])*(y[i+]-y[i]));
t2=sqrt((x[i]-x[i-])*(x[i]-x[i-])+(y[i]-y[i-])*(y[i]-y[i-]));
t3=sqrt((x[i-]-x[i+])*(x[i-]-x[i+])+(y[i-]-y[i+])*(y[i-]-y[i+]));
}
//cout<<t1<<" "<<t2<<" "<<t3<<" ";
ankle[i]=acos((t1*t1+t2*t2-t3*t3)/(*t1*t2));
//cout<<ankle[i]<<" ";
//cout<<endl;
} double l=;
for(int i=;i<=n;i++)
{
l+=sqrt(dis[i])*(acos(-1.0)-ankle[i]);
}
printf("Case #%d: %.3lf\n",case1,l);
}
return ;
}

Codeforces gym102222 B.Rolling The Polygon 凸包/余弦定理的更多相关文章

  1. Codeforces 437E The Child and Polygon(间隔DP)

    题目链接:Codeforces 437E The Child and Polygon 题目大意:给出一个多边形,问说有多少种切割方法.将多边形切割为多个三角形. 解题思路:首先要理解向量叉积的性质,一 ...

  2. hdu 4033Regular Polygon(二分+余弦定理)

    Regular Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)T ...

  3. POJ 2007 Scrambled Polygon 凸包

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7214   Accepted: 3445 ...

  4. POJ 2007 Scrambled Polygon [凸包 极角排序]

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 ...

  5. 【codeforces 755D】PolandBall and Polygon

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. Codeforces 437E The Child and Polygon

    http://codeforces.com/problemset/problem/437/E 题意:求一个多边形划分成三角形的方案数 思路:区间dp,每次转移只从一个方向转移(L,R连线的某一侧),能 ...

  7. Codeforces 1045E. Ancient civilizations 构造 计算几何 凸包

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF1045E.html 4K码量构造题,CF血腥残暴! 题解 首先,如果所有点颜色相同,那么直接连个菊花搞定. ...

  8. POJ 2007 Scrambled Polygon 凸包点排序逆时针输出

    题意:如题 用Graham,直接就能得到逆时针的凸包,找到原点输出就行了,赤果果的水题- 代码: /* * Author: illuz <iilluzen[at]gmail.com> * ...

  9. 计蒜客 The 2018 ACM-ICPC Chinese Collegiate Programming Contest Rolling The Polygon

    include <iostream> #include <cstdio> #include <cstring> #include <string> #i ...

随机推荐

  1. [六省联考2017]分手是祝愿 题解(期望dp)

    题目描述 B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 1 到 n 的正整数. 每个灯有两个状态亮和灭,我们用 1 来表示这个灯是亮的,用 0 表示 ...

  2. Ajax,ajax封装

    /** * Created by liyinghao on 2016/8/23. */ /*仿jQuery中的ajax方法,简单版实现;封装ajax的工具函数*/ /* * 1 请求方式 type g ...

  3. 运维 03 Linux之文档与目录结构

    Linux之文档与目录结构   Linux文件系统结构 Linux目录结构的组织形式和Windows有很大的不同.首先Linux没有“盘(C盘.D盘.E盘)”的概念.已经建立文件系统的硬盘分区被挂载到 ...

  4. 数学&计算机工程常用希腊字母表及其发音

  5. Anjular的ng-repeat

    Anjular的ng-repeat不会循环一个二维集合中的一维集合.举个例子:集合 list=  {1,2,{0,1,2},23,222},small={0,1,2},使用ng-repeat" ...

  6. git 关于commit命令的修改

    1 修改最后一次提交的信息 git commit --amend 2 对于历史提交 git rebase -i HEAD~5 没毛病,

  7. 数据持久化之嵌入式数据库 SQLite(三)

    阿里P7Android高级架构进阶视频免费学习请点击:https://space.bilibili.com/474380680 SQLite 是 D. Richard Hipp 用 C 语言编写的开源 ...

  8. 《linux 内核全然剖析》sched.c sched.h 代码分析笔记

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011368821/article/details/25129835 sched.c sched.h ...

  9. BUUCTF PWN部分题目wp

    pwn好难啊 PWN 1,连上就有flag的pwnnc buuoj.cn 6000得到flag 2,RIP覆盖一下用ida分析一下,发现已有了system,只需覆盖RIP为fun()的地址,用peda ...

  10. Invoke-Obfuscation混淆ps文件绕过Windows_Defender

    前提 powershell只能针对win7之后的系统,之前的win操作系统默认没有安装powershell. 所在目录:C:\Windows\System32\WindowsPowerShell\v1 ...