hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700
Points on Cycle
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1567 Accepted Submission(s): 570
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.
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.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#define eps 0.0005
#define pi 3.14159265
int main()
{
int n,m,i,j;
scanf("%d",&n);
while(n--)
{
double x1,y1,x2,y2,x3,y3;
double Q1=pi*/,Q2=pi*/;
scanf("%lf%lf",&x1,&y1);
x2=x1*cos(Q1)-y1*sin(Q1);
y2=y1*cos(Q1)+x1*sin(Q1);
x3=x1*cos(Q2)-y1*sin(Q2);
y3=y1*cos(Q2)+x1*sin(Q2);//printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
if(fabs(y2-y3)<eps)
{
if((x2-x3)>eps)
printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
else
{
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
}
}
else if((y2-y3)>eps)
printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
}
return ;
}
任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:
x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;
y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;
hdu 1700 Points on Cycle(坐标旋转)的更多相关文章
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
- HDU 1700 Points on Cycle(向量旋转)
题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ...
- HDU 1700 Points on Cycle (几何 向量旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...
- hdu 1700 Points on Cycle 水几何
已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio&g ...
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
Points on Cycle Time Limit:1000MS Memory Limit:32768 ...
- L - Points on Cycle(旋转公式)
L - Points on Cycle Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU-1700 Points on Cycle
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
随机推荐
- PHPCMS V9 学习总结
在实现PHPCMS网站过程中,根据业务需求,我们遇到很多问题,特此总结如下,以便大家参考学习. [1]PHPCMS V9系统目录简析 在研究所有问题之前,请先了解一下系统的文件目录结构,具体如下图所示 ...
- php 缓存加速器软件
Xcache 和 memcached 是两个不同层面的缓存,不存在可比性.Xcache 是 php 底层的缓存,它将PHP程式编译成字节码(byte code),再透过服务器上安装对应的程式来执行PH ...
- React笔记_(7)_react路由
路由 路由(routing)是指分组从源到目的地时,决定端到端路径的网络范围的进程. 路由器当然是作为一个转发设备出现的,主要是转发数据包来实现网络互联. 那么react的路由到底指的是什么呢? 举个 ...
- ubuntu apache开启重写模块
http://www.iblue.cc/2011/09/ubuntu-apache%E5%BC%80%E5%90%AF%E9%87%8D%E5%86%99%E6%A8%A1%E5%9D%97/ Ubu ...
- linux信号机制 - 用户堆栈和内核堆栈的变化【转】
转自:http://itindex.net/detail/16418-linux-%E4%BF%A1%E5%8F%B7-%E5%A0%86%E6%A0%88 此文只简单分析发送信号给用户程序后,用户堆 ...
- js获取IP地址方法总结_转
js代码获取IP地址的方法,如何在js中取得客户端的IP地址.原文地址:js获取IP地址的三种方法 http://www.jbxue.com/article/11338.html 1,js取得IP地址 ...
- 5、XML(1)
1 XML入门 1.1 引入 HTML: 负责网页的结构 CSS: 负责网页的样式(美观) Javascript: 负责在浏览器端与用户进行交互. 负责静态的网页制作的语言 HTML语言特点: 1)由 ...
- c# 之五行地支
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 批量解密SQLSERVER数据库中的各种对象的工具dbForge SQL Decryptor2.1.11
参考地址: http://www.cnblogs.com/lyhabc/p/3505677.html SQLPROMPT5.3对各种加密对象的解密测试 SQL2005解密已经被加密的存储过程 昨天ah ...
- phpcms 03
继续上次对header.html文件的分析 logo<a href="{siteurl($siteid)}/"><img src="{IMG_PATH} ...