2019银川网络赛 Rolling The Polygon  简单的计算几何
Bahiyyah has a convex polygon with n vertices P0,P1,……,Pn−1 in the counterclockwise order. Two vertices with consecutive indexes are adjacent, and besides, P0 and Pn−1 are adjacent. She also assigns a point Q inside the polygon which may appear on the border.Now, Bahiyyah decides to roll the polygon along a straight line and calculate the length of the trajectory (or track) of point Q.To help clarify, we suppose Pn P0,Pn1 P1 and assume the edge between P0 and P1 is lying on the line at first.At that point when the edge between Pi−1 and Pi lies on the line, Bahiyyah rolls the polygon forward rotating the polygon along the vertex Pi until the next edge (which is between Pi and Pi1 ) meets the line. She will stop the rolling when the edge between Pn and Pn1 (which is same as the edge between P0and P1 ) meets the line again.输入The input contains several test cases, and the first line is a positive integer T indicating the number of test cases which is up to 50.For each test case, the first line contains an integer n (3≤n≤50) indicating the number of vertices of the given convex polygon. Following n lines describe vertices of the polygon in the counterclockwise order. The i-th line of them contains two integers xi−1 and yi−1 , which are the coordinates of point Pi−1 . The last line contains two integers xQ and yQ , which are the coordinates of point Q.We guarantee that all coordinates are in the range of -103 to 103 , and point Q is located inside the polygon or lies on its border.输出For each test case, output a line containing Case #x: y, where x is the test case number starting from 1, and y is the length of the trajectory of the point Q rounded to 3 places. We guarantee that 4-th place after the decimal point in the precise answer would not be 4 or 5.样例输入复制样例数据4 4 0 0 2 0 2 2 0 2 1 1 3 0 0 2 1 1 2 1 1 5 0 0 1 0 2 2 1 3 -1 2 0 0 6 0 0 3 0 4 1 2 2 1 2 -1 1 1 0样例输出Case #1: 8.886 Case #2: 7.318 Case #3: 12.102 Case #4: 14.537提示The following figure is the the trajectory of the point Q in the fi rst sample test case.虽然是原题但是自己比赛的时候没做出来。主要因为当时读错题了。。。赛后理解对题意之后这个题竟然还看个四十多分钟总结一下吧。题意 给定一个凸多边形和多边形内的一点按逆序给出。问这个多边形绕着自己的边旋转一周这个点走过的距离。注意是绕着自己的边我以为是绕着x或y轴所以一直不知道如何下手。思路先看下画的图吧是第二个样例的图可以很清晰的发现就是转了一个角度这个角度就是它所对应角的补角互为补角是相加180度高中的数学都快忘了哈哈哈。然后用余弦定理求acos值就可以了对应每条边注意i1和in时对应的边的小细节。然后用扇形的弧度公式求解长度就可以了。S长度R半径*acos角度#includebits/stdc.h #define mem(a,b) memset(a,b,sizeof(a)) #define ll long long #pragma GCC optimize(2) #define PI 3.1415926 double esp1e-10; using namespace std; const int maxx1e415; struct stu { double x,y; double juli;//半径 }A[maxx]; int main() { ll i,j,k,t,x; ll n,m; scanf(%lld,t); for(int p1;pt;p) { scanf(%lld,n); double changdu0; for(i1;in1;i) { scanf(%lf%lfd,A[i].x,A[i].y); } for(i1;in;i) { A[i].juli(A[i].x-A[n1].x)*(A[i].x-A[n1].x)(A[i].y-A[n1].y)*(A[i].y-A[n1].y); A[i].julisqrt(A[i].juli); } A[0].xA[n].x; A[0].yA[n].y; A[n1].xA[1].x; A[n1].yA[1].y; for(i1;in;i) { double a1(A[i].x-A[i1].x)*(A[i].x-A[i1].x)(A[i].y-A[i1].y)*(A[i].y-A[i1].y); double b1(A[i].x-A[i-1].x)*(A[i].x-A[i-1].x)(A[i].y-A[i-1].y)*(A[i].y-A[i-1].y); double c1(A[i-1].x-A[i1].x)*(A[i-1].x-A[i1].x)(A[i-1].y-A[i1].y)*(A[i-1].y-A[i1].y); a1sqrt(a1);b1sqrt(b1);c1sqrt(c1); double jiaoduacos((a1*a1b1*b1-c1*c1)/(2*a1*b1)); changdu(acos(-1.0)-jiaodu)*(A[i].juli);// 弧度公式 } printf(Case #%d: %.3lf\n,p,changdu); } return 0; }补题不重要重要的是回顾一下这样的小知识以后别蠢蠢的连这种水题都做不出来。。。

相关新闻

【单片机毕业设计推荐】基于 STM32 的环境温湿度与水位智能监控系统设计,基于 STM32 的加湿补水智能控制与语音报警系统设计(011604)

【单片机毕业设计推荐】基于 STM32 的环境温湿度与水位智能监控系统设计,基于 STM32 的加湿补水智能控制与语音报警系统设计(011604)

文章目录20 个相关毕业设计备选题目项目研究背景摘要总体方案核心功能基础功能核心功能辅助功能技术路线项目演示关于我们项目案例源码获取温馨提示:本人主页置顶文章(点我)有 CSDN 平台官方提供的学长联系方式的名片! 温馨提示:本人主页置顶…

2026/11/6 9:42:32 阅读更多 →
转发(Forward)和重定向(Redirect)的区别

转发(Forward)和重定向(Redirect)的区别

转发是服务器行为,重定向是客户端行为。 转发(Forward) 通过RequestDispatcher对象的forward(HttpServletRequest request,HttpServletResponse response)方法实现的。RequestDispatcher可以通过HttpServletRequest 的…

2026/11/4 18:18:58 阅读更多 →
斐波那契查找出现的问题及解决方法

斐波那契查找出现的问题及解决方法

先看看斐波那契查找方法 斐波那契数列 1 1 2 3 5 8 13 21 … 斐波那契数列 的前一项f[k-1]/f[k] 随着k越来越大,这个值逐渐趋近黄金分割点0.618 如果查找的数据长度等于斐波那契数列的某一项数。则可以直接进行查找,否则 就需要将查找目标数组进行扩列…

2026/11/2 16:51:40 阅读更多 →

最新新闻

Electron桌面应用开发实战:从环境搭建到打包发布全流程

Electron桌面应用开发实战:从环境搭建到打包发布全流程

做前端这些年,我大部分时间都在跟浏览器标签页打交道,直到第一次把桌面应用跑起来,才发现原来自己一直被限制在地址栏和刷新按钮围起来的框框里。Electron这个词,最开始是在某段时间频繁出现在同事的讨论里,一个用HTML…

2026/11/5 12:28:00 阅读更多 →
滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

简介:亚太天能T109滑盖智能锁产品说明书是一份PDF格式的官方技术文档,主要面向智能锁安装人员、终端用户及售后维护者,帮助快速掌握产品安装、配置与常见故障处理。全包仅1个PDF文件,大小4.37MB,内容结构清晰&#xff…

2026/11/6 9:29:27 阅读更多 →
PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

上个月我在调试一台高速AGV的驱动系统,整车要求空载跑到8m/s,电机转速已经拉到额定点,驱动器的输出电压也顶到了母线电压极限附近。再往上踩速度指令,转速纹丝不动,三相电流反而开始震荡。那会儿我的第一反应就是&…

2026/11/5 12:28:01 阅读更多 →
C++核心知识点:从内存管理到STL的实战指南

C++核心知识点:从内存管理到STL的实战指南

C 这门语言我前前后后折腾了十几年,用它写过嵌入式驱动、做过游戏服务端,也搭过基础组件库。每次看到新人一头扎进"C 核心知识点"这个搜索词,我其实挺感慨的——这门语言的难点从来不是语法多,而是知识点之间的耦合太深…

2026/11/5 12:28:02 阅读更多 →
T109滑盖智能锁怎么装?安装调试与故障排查全攻略

T109滑盖智能锁怎么装?安装调试与故障排查全攻略

简介:亚太天能T109滑盖智能锁产品说明书以PDF格式发布,适合智能锁用户、安装人员与售后维修人员阅读。内容围绕T109系列指纹密码刷卡锁展开,先介绍前面板、后面板、锁体、机械钥匙、电池盒盖等部件名称与功能,再给出完整安装步骤&…

2026/11/6 8:08:42 阅读更多 →
LLM知识降熵:从信息垄断到理解权下放

LLM知识降熵:从信息垄断到理解权下放

你有没有过这种经历:翻开源码注释、论文摘要或者一份专业报告,每个字都认识,连在一起却像天书。想找人聊聊,身边要么没人懂,要么懂的懒得跟你解释。后来我试着把同一段内容丢给一个大语言模型,几秒钟之后&a…

2026/11/5 19:38:59 阅读更多 →

日新闻

周新闻

月新闻