题目描述

For the UCF High School Programming Tournament, the judges were located in the Engineering building, and most of the teams were in the Classroom building, which is on the other side of Pegasus Circle.

Chris was walking to the Classroom building for the first time, and was joined by Jeremy, who had made the hike a couple of times already.

“Jeremy, is it faster to stay on the circle, or to cut through the middle using the boardwalks that go to the Student Union?” asked Chris.

“I don’t know.” Jeremy answered. “I think it’s about the same, but it might be slightly faster to use the walkways.”

“Well, if it’s about the same, let’s stick to the circle. I don’t want to be attacked by squirrels.”

The Problem:

Given two points on a circle, and two paths to get from one to the other—one following the perimeter of the circle, and the other by a sequence of connected straight line segments through the interior of the circle—determine the shorter of the two paths.

输入描述:

The input will contain multiple test cases, each consisting of two lines. The first line of each testcase contains six floating-point numbers:xc,yc,xs,ys,xf, andyf, where (xc,yc) is the center point of the circle, (xs,ys) is the start point for both paths (e.g., the Engineering building), and (xf,yf) is the finish point for both paths (e.g., the Classroom building).The circle will always have a radius greater than 1, and the start and finish points are both guaranteed to be at distinct pointson its perimeter, with an accuracy of at least 3 placesafter the decimal.The path along the perimeter is always in the directioncounter-clockwise around the circle.

The second line of each test case will start with an integer,n(1≤n≤ 10), followed by n pairs of floating-point numbers,x1,y1,x2,y2, …xn, and yn, where each pair (xi,yi) is a point inside the circle. The interior path traveled will be from point (xs,ys) to point (x1,y1), then from (x1,y1) to (x2,y2), then from (x2,y2) to (x3,y3), …, then from (xn,yn) to (xf,yf).

The last test case will be followed by a line containing six zeros. All numbers on an input line will beseparated from each other by one space, with no extra spaces at the beginning or end of lines. Assumethat all the input floating point numbers will be less than 1000.0 and greater than

-1000.0, with at most 6 places after the decimal.

输出描述:

For each test case in the input, output a line in either the format

Case #n:Stick to the Circle.

if the perimeter path is shorter,or

Case #n:Watch out for squirrels!

if the interior pathis shorter, where n is the num berof the input test case, starting at 1.

Assume that the two paths will not be equal, i.e., it is guaranteed that the two distances will not be equal. In particular, assume that the two paths will differ in length by 0.001 or more.

Leave a blank line after the output for each test case.

输入

5.0 5.0 10.0 5.0 5.0 10.0
6 8.5 4.7 6.9 5.0 3.6 6.5 4.2 7.1 4.2 8.3 4.7 8.8
2.0 8.0 0.5 16.87412 7.5 0.8761
2 3.25 9.25 7.0 7.0
0 0 0 0 0 0

输出

Case #1: Stick to the Circle.

Case #2: Watch out for squirrels!

AC的C++代码

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;int main()
{       int flag=1;double x0;while(~scanf("%lf",&x0)){//第一行double y0,x1,y1,x2,y2;cin>>y0>>x1>>y1>>x2>>y2;if(x0==0 && y0==0 && x1==0 && x2==0 && y1==0 && y2==0)break;//求弧长double   r = sqrt( (x1-x0)*(x1-x0)+(y1-y0)*(y1-y0) );double L1 = r * acos( ((x1-x0)*(x2-x0)+(y1-y0)*(y2-y0)) / (r*r) );// 第二行int N;double L2=0,x,y,a,b,c,d;cin>>N;a=x1,b=y1;for(int i=1; i<=N; i++){cin>>c>>d;L2 += sqrt( (c-a)*(c-a)+(d-b)*(d-b) );a=c,b=d;}L2 += sqrt( (x2-a)*(x2-a)+(y2-b)*(y2-b) );cout << "Case #"<<flag<<": ";flag++;if(L1 < L2)cout<<"Stick to the Circle."<<"\n\n";elsecout<<"Watch out for squirrels!"<<"\n\n";      }
}

牛客 2021年度训练联盟热身训练赛第二场 I题Pegasus Circle Shortcut相关推荐

  1. 2021年度训练联盟热身训练赛第三场赛后补题

    2021年度训练联盟热身训练赛第三场赛后补题 A Circuit Math [题目分析] [代码展示] B Diagonal Cut [题目分析] [代码展示] C Gerrymandering [题 ...

  2. 2021年度训练联盟热身训练赛第三场(待补)

    文章目录 前言 一.Circuit Math(后缀表达式---栈&&fgets) 二.Diagonal Cut(gcd最大公因数,数论) 三.expected primary-expr ...

  3. 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FFT)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 2021年度训练联盟热身训练赛第四场 H - Rock Paper Scissors(字符串匹配,FF ...

  4. 2021年度训练联盟热身训练赛第五场

    2021年度训练联盟热身训练赛第五场 链接:https://ac.nowcoder.com/acm/contest/13926 A Binary Seating #include<bits/st ...

  5. 2021年度训练联盟热身训练赛第八场

    目录 2021年度训练联盟热身训练赛第八场 A-Fire on Field 题意 思路 代码 B-Gene Tree 题意 思路 代码 I-Thread Knots 题意 思路 代码 J-Triang ...

  6. 2021年度训练联盟热身训练赛第二场(ICPC North Central NA Contest 2019,南阳师范学院),签到题ABCDEFGIJ

    A. Binarize It,简单枚举 链接:https://ac.nowcoder.com/acm/contest/12794/A 来源:牛客网 题目描述 Professor Boolando ca ...

  7. 2021年度训练联盟热身训练赛第二场(全)

    传送门 怎么说呢,这次的训练赛的题目难度不是很大,但就是字多 A Binarize It Professor Boolando can only think in binary, or more sp ...

  8. 2021年度训练联盟热身训练赛第五场F题Group Project

    题意: 有n个人,其中有m组,两两互斥,现在要分成两个班,但最终求的确是最多有多少对不互斥的. 题目: 链接:https://ac.nowcoder.com/acm/contest/16741/F 来 ...

  9. 2021年度训练联盟热身训练赛第五场 H题In-place Sorting+贪心构造

    题意: 给你n个小于101810^{18}1018的大数,问在可以再不改变序列位置,之改变数值中某数位的'9'变为'6'或将'6'变为'9',求的最终序列由小到大,且字典序最小. 题目: 链接:htt ...

最新文章

  1. 事务处理不当,线上接口又双叒内存泄漏了!(附图解问题全过程)
  2. 图形旋转的C语言源程序
  3. java基础之构造方法
  4. what is the meaning of bring you up to speed?
  5. 在linux下创建自定义service服务
  6. 水解聚丙烯酰胺 php,聚丙烯酰胺水溶液的流变性质
  7. python复数运算程序_python复数-python,复数
  8. sql交叉表查询_初学前端需要注意什么 SQL连接相关内容有哪些
  9. 针对笔记本电源已接通未充电的提示怎么办
  10. 680.验证回文字符串(力扣leetcode) 博主可答疑该问题
  11. 如何在Linux上执行exe文件
  12. php爬虫框架phpspider,第一次使用php编写爬虫,使用了phpspider包
  13. 文件下载-解决IOS自带浏览器下载乱码的问题
  14. 用MeGUI压制720x480 MP4视频,详细教程[面向有一定基础者]
  15. c语言水王争霸链表,水王争霸
  16. [UOJ449][概率DP]集训队作业2018:喂鸽子
  17. c语言编程数字后有ul,十六进制数后跟L/U/UL解析
  18. Python--基础语法知识
  19. 机器学习-2.Python机器学习软件包Scikit-Learn的学习与运用
  20. 小程序拨打电话功能,微信小程序点击手机号,拨打电话~!

热门文章

  1. Android - Earthquake工程(地震监测) 的 对
  2. 跨网页张贴(Cross-Page Posting),微软称为「跨网页公布」 #1
  3. Mock(模拟后端接口数据)配合Vuex的使用
  4. 第25月第3天 Mxshop项目记录01
  5. AC自动机 学习链接
  6. AutoMap1.0发布
  7. 从头开始-02.C语言基础
  8. 垂涎欲滴!30个美味的食品类移动应用程序【下篇】
  9. Sql Server 行转列学习 根据学生表、课程表、学生成绩表统计每个学生的各科成绩和他的总成绩、平均成绩...
  10. 【恋上数据结构】图代码实现、BFS、DFS、拓扑排序