暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
Input
Output
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.
Sample Input
1.500 2.000
563.585 1.251
Sample Output
-280.709 -488.704 -282.876 487.453
问题分析:它是一道几何题,假设以知点a坐标为(x0,y0),位置点b,c为(x1,y1),(x2,y2). 圆方程为x2+y2 = r2;可将圆方程化为x=rcosα,y=rsinα;
又有x12+y1 2= r2 = x02+y0 2,(a*b)/|a|*|b| = cos120。
易得 acosα + bsinα = -0.5r
(acosα)2 = (0.5r + bsinα)2
r2sinα2 + rbsinα + 0.25r2 - a2 = 0
得 x1 = -0.5*b + a*√3 * 0.5 或 x1 = -0.5*b - a*√3 *0.5(舍去)
及 y = -0.5*b - a*√3 * 0.5 或 y= 0.5*b + a*√3 * 0.5(舍去)
同理可得x2,y2;
也可直接利用cos(α+β) = cosαcosβ - sinαsinβ ,sin(α+β) = sinαcosβ + cosαsinβ求解,
#include <cstdio>
#include <cmath>
int main()
{
double a,b,x0,y0,x1,y1,x2,y2;
int t;
a=sqrt(3.0)/;
b=-0.5;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x0,&y0);
x1 = b*x0 - a*y0;
y1 = b*y0 + a*x0;
x2 = b*x0 + a*y0;
y2 = b*y0 - a*x0;
if(y1<y2 || ((fabs(y1-y2) < 0.005) && x1 < x2))
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x1,y1);
}
return ;
}
暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)的更多相关文章
- 2016HUAS暑假集训训练2 L - Points on Cycle
题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/L 这是一道很有意思的题,就是给定一个以原点为圆心的圆,然后给定 一个点 求最大三 ...
- 暑假集训(3)第二弹 -----Jungle Roads(Hdu1301)
问题梗概:自从上次某个acmer来设计了拉格瑞圣岛的交通路线后,岛上的酋长就相当苦恼,他发现,虽然这些修好的公路便利了岛上的 交通,并且让拉格瑞圣岛的旅游业更加兴旺,甚至他们还收到了一笔不小的国际资金 ...
- 暑假集训(1)第二弹 -----Catch the cow(Poj3278)
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...
- 暑假集训(5)第二弹———湫湫系列故事——减肥记I(hdu4508)
问题描述:舔了舔嘴上的油渍,你陷在身后柔软的靠椅上.在德源大赛中获得优胜的你,迫不及待地赶到“吃到饱”饭店吃到饱.当你 正准备离开时,服务员叫住了你,“先生,您还没有吃完你所点的酒菜.”指着你桌上的一 ...
- 暑假集训(5)第一弹——— Super Jumping! Jumping! Jumping!(hdu1087)
题意概括:在上次与娑殚的三次博弈中,你们都取得了胜利.便向娑殚提出要求,借助他的力量,传送到一个安全的地方. 你们的愿望达成了,不过,你和小A似乎失散了. 街上人来人往的特别热闹,每一个人的脸上都洋溢 ...
- 暑假集训(4)第二弹 -----递推(hdu2254)
题意概括:上次小A在你的帮助下成功炼成贤者法阵的第一部分——三角分隔,现在他准备绘制法阵的第二部分——莫测矩形. 而他又遇到了一个问题,他不知道不同矩形到底有多少个. 秉持帮人帮到底,送佛送到西的基本 ...
- 暑假集训(4)第一弹 -----递推(Hdu2039)
题意梗概:fff团团员小A想退团了,不过要退团,他必须绘制出贤者法阵,以证明他有资格不受大fff之灵的监督 并退团,小A他现在要开始收集材料了,但是,他不清楚应该买多少份材料. 虽然你并不想帮他退团, ...
- 暑假集训(3)第一弹 -----还是畅通工程(hdu1233)
题意梗概:N(n<100)个村子想要富起来,自然就要先修路,不过到底还是没富起来,所以陷入了一个怪圈 :资金不足->修不起路->资金不足...... 为了实现走向全民小康社会,全面实 ...
- 暑假集训(2)第二弹 ----- The Suspects(POJ1611)
B - The Suspects Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:20000KB ...
随机推荐
- HW2.17
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HDU-1814 Peaceful Commission 2sat
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1814 简单的2sat题. //STATUS:C++_AC_390MS_996KB #include & ...
- mysql 中文乱码的解决办法
I would not suggest Richies answer, because you are screwing up the data inside the database. You wo ...
- java中服务器启动时,执行定时任务
package com.ripsoft.util; import java.util.Calendar; import java.util.Timer; import javax.servlet.Se ...
- Linux为Tomecat指定JDK
在搭建Jenkin+Sonar集成时,由于系统环境配置了jdk1.7,但是jenkins在安装sonar的插件时,需要jdk1.8.,所以需要在Tomcat指定jdk1.8. (1)暂停Tomcat ...
- elasticsearch的基本用法
开始学习使用 elasticsearch, 把步骤记录在这里: 最大的特点: 1. 数据库的 database, 就是 index 2. 数据库的 table, 就是 tag 3. 不要使用bro ...
- 动态加载JS文件,并根据JS文件的加载状态来执行自己的回调函数
动态加载JS文件,并根据JS文件的加载状态来执行自己的回调函数, 在很多场景下,我们需要在动态加载JS文件的时候,根据加载的状态来进行后续的操作,需要在JS加载成功后,执行另一方法,这个方法是依托在加 ...
- NSAutoreleasePool' is unavailable: not avail
NSAutoreleasePool' is unavailable: not available in automatic reference counting mode 这我就纠结了,对着书敲都出问 ...
- SqlServer数据库的一些方法的用途
一直分不清这三种方法的具体用法现在终于找齐了 ExecuteNonQuery方法和ExecuteScalar方法和ExecuteReader方法的区别 (1)ExecuteNonQuery():执行命 ...
- Log4E
工具地址:http://marketplace.eclipse.org/content/log4e Log4E插件能够帮助你在Java项目中轻松地创建记录器.它可以在以下几个任务中提供帮助:记录器声明 ...