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/7/28 17:58:03 阅读更多 →
转发(Forward)和重定向(Redirect)的区别

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

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

2026/7/28 17:58:03 阅读更多 →
斐波那契查找出现的问题及解决方法

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

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

2026/7/28 17:58:03 阅读更多 →

最新新闻

sklearn.linear_model.LogisticRegression()函数解析(最清晰的解释)

sklearn.linear_model.LogisticRegression()函数解析(最清晰的解释)

欢迎关注WX公众号:【程序员管小亮】 sklearn.linear_model.LogisticRegression()函数全称是Logistic回归(aka logit,MaxEnt)分类器。 class sklearn.linear_model.LogisticRegression(penaltyl2, dualFalse, tol0.0001, C1.0, f…

2026/7/28 18:08:06 阅读更多 →
PHP:数组函数(1)

PHP:数组函数(1)

数组函数: 1.需求: 1)获取数组中的value. function getval($arr){foreach($arr as $key>$val){$row[]$val;}return $row; }** <?php $arrarray(item1>linux,item2>php,item3>java,item4>mysql,item5>jquery );// 数组遍历foreach($arr as $key>$val){…

2026/7/28 18:08:06 阅读更多 →
NBM7100A与PIC18F56K42实现超低功耗物联网设备设计

NBM7100A与PIC18F56K42实现超低功耗物联网设备设计

1. 项目背景与核心挑战在物联网设备和便携式电子产品的设计中&#xff0c;如何最大化初级电池&#xff08;不可充电电池&#xff09;的使用寿命一直是个关键难题。我最近在一个野外环境监测项目中使用NBM7100A电源管理芯片搭配PIC18F56K42微控制器&#xff0c;成功将CR2032纽扣…

2026/7/28 18:08:06 阅读更多 →
关于MySQL多表关联时过滤条件的位置

关于MySQL多表关联时过滤条件的位置

简单的一个Demo说明下问题表A和表B关联查询&#xff0c;以project_id4为过滤条件&#xff0c;查询结果返回表A中的ID&#xff0c;name&#xff0c;表B中的project_id,如果表B中没有和表A匹配的记录则a.project_id返回null&#xff0c;于是第一次我就写出了这样的SQLSELECTt.id,…

2026/7/28 18:08:06 阅读更多 →
eclipse使用alt+/很卡的解决方法

eclipse使用alt+/很卡的解决方法

1、点击报错的那个连接&#xff08;Content Assist) ,或者 打开 Windows>preferences>Java>Editor>Content Assist>Advanced2、将Default Proposal Kinds栏中(上面框)Java Proposals (Code Recommenders)取消对勾。3、生效后&#xff0c;我的就没有提示&#xf…

2026/7/28 18:08:06 阅读更多 →
从日本书法到中文排版:霞鹜文楷如何成为免费字体中的“黑马“?

从日本书法到中文排版:霞鹜文楷如何成为免费字体中的“黑马“?

从日本书法到中文排版&#xff1a;霞鹜文楷如何成为免费字体中的"黑马"&#xff1f; 【免费下载链接】LxgwWenKai An unprofessional open-source Chinese font derived from Fontworks Klee One. 一款非专业的开源中文字体&#xff0c;基于 FONTWORKS 出品字体 Klee…

2026/7/28 18:07:06 阅读更多 →

日新闻

告别臃肿!3步让你的暗影精灵笔记本重获新生

告别臃肿!3步让你的暗影精灵笔记本重获新生

告别臃肿&#xff01;3步让你的暗影精灵笔记本重获新生 【免费下载链接】OmenSuperHub Control Omen laptop performance, fan speeds, and keyboard lighting, and unlock power limits. 项目地址: https://gitcode.com/gh_mirrors/om/OmenSuperHub 你是否也曾为官方Om…

2026/7/28 0:00:43 阅读更多 →
RAG必踩坑!财报法规检索不准?这款开源工具让答案浮出水面,准确率飙升98.7%!

RAG必踩坑!财报法规检索不准?这款开源工具让答案浮出水面,准确率飙升98.7%!

做 RAG 的人应该都踩过这个致命的坑&#xff1a;把几百页的财报、法规、技术手册扔给向量库&#xff0c;问一个具体问题&#xff0c;搜出来的全是沾边但没用的内容 —— 关键信息要么被硬切块拆碎了&#xff0c;要么藏在几十条结果的最下面。语义相似≠真正相关&#xff0c;这个…

2026/7/28 0:00:43 阅读更多 →
抖音视频文案提取工具全指南:免费2026版、手机App、在线工具一网打尽

抖音视频文案提取工具全指南:免费2026版、手机App、在线工具一网打尽

2026年做短视频运营&#xff0c;从抖音上扒文案早就不是偷偷抄笔记的事了。我刚开始做内容的时候&#xff0c;每天刷半小时抖音&#xff0c;手动把爆款视频的口播敲进备忘录&#xff0c;一条2分钟的视频得花十来分钟&#xff0c;碰到语速快的还要反复回听。后来试了一圈工具&am…

2026/7/28 0:00:43 阅读更多 →

周新闻

深度学习道路桥梁裂缝检测系统 道路桥梁裂缝检测数据集 道路桥梁病害识别检测数据集

深度学习道路桥梁裂缝检测系统 道路桥梁裂缝检测数据集 道路桥梁病害识别检测数据集

深度学习道路桥梁裂缝检测系统 数据集6000张 完整源码已标注数据集训练好的模型环境配置教程程序运行说明文档&#xff0c;可以直接使用&#xff01;系统支持图片、视频、摄像头等多种方式检测裂缝&#xff0c;功能强大实用。 1数据集6000张 8各类别

2026/7/28 12:04:22 阅读更多 →
深度学习YOLO模型如何训练 PUBG 绝地求生目标检测数据集

深度学习YOLO模型如何训练 PUBG 绝地求生目标检测数据集

pubg数据集 精选原图1.42万数据 1.49万标签 无任何重复、算法增强或冗余图像&#xff01; pubg绝地求生目标检测数据集 1分类&#xff1a;e_body&#xff0c;14905个标签&#xff0c;txt格式 共计14244张图&#xff0c;99%为640*640尺寸图像 适合yolo目标检测、AI训练关键词&am…

2026/7/28 8:29:16 阅读更多 →
Apex英雄目标检测数据集 深度学习框架YOLO如何训练APEX数据集

Apex英雄目标检测数据集 深度学习框架YOLO如何训练APEX数据集

Apex检测数据集数据集详情检测类别&#xff1a; allies enemy tag图片总量&#xff1a;7247张训练集&#xff1a;5139张验证集&#xff1a;1425张测试集&#xff1a;683张标注状态&#xff1a;全部已标注&#xff0c;即拿即用数据格式&#xff1a;支持YOLO格式及其他格式&#…

2026/7/28 5:03:42 阅读更多 →

月新闻