题意:

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

题解:

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

#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. CF1061E Politics E. Politics 解题报告

    CF1061E Politics E. Politics 考虑利用树的性质,因为是子树问题,所以放到dfs序上. 只考虑一个树,问题是每个区间选恰好\(k\)个.因为区间其实是子树,所以区间要么包含, ...

  2. ZROI week6

    ZROI week6 T1 用一个类似背包的东西记录答案. T2 好像直接用|操作即可. T3 瞎搞就完事了 T4 启发式合并,然而变量写错了,就没了... 总结 100 + 100 + 100 + ...

  3. QC增加Test、Defect字段

    QC--Tools--customization,在Project Entities中增加字段,在Project Lists中编辑Lookup List类型字段的指定值

  4. EFK搜集MySQL慢日志

    前提已经安装好EFK 1.在MySQL节点安装td-agent http://packages.treasuredata.com.s3.amazonaws.com/3/redhat/7/x86_64/ ...

  5. HTML5: HTML5 内联 SVG

    ylbtech-HTML5: HTML5 内联 SVG 1.返回顶部 1. HTML5 内联 SVG HTML5 支持内联 SVG. 什么是SVG? SVG 指可伸缩矢量图形 (Scalable Ve ...

  6. 52、saleforce 第一篇

    View the Schema 1.点击setup 2.在QuickFind and Search中输入Schema Builder 先点击clear all 去除所有现实的UML,然后选择Line_ ...

  7. ES6数组中删除指定元素

    知识点: ES6从数组中删除指定元素 findIndex()方法返回数组中满足提供的测试函数的第一个元素的索引.否则返回-1. arr.splice(arr.findIndex(item => ...

  8. 百度之星资格赛2018B题-子串查询

    子串查询 题目 度度熊的字符串课堂开始了!要以像度度熊一样的天才为目标,努力奋斗哦! 为了检验你是否具备不听课的资质,度度熊准备了一个只包含大写英文字母的字符串 A[1,n]=a1a2⋯an,接下来他 ...

  9. Rust <9>:启用第三方库的备选 features

  10. 火狐foxyproxy + burp

    下载 火狐foxyproxy 和 burp 两个代理ip端口填写一致 如果对于公司有正向代理服务器,则需要配置burp的上游代理 对于IE浏览器的代理是windows操作系统的全局代理,在ie配置代理 ...