山东省赛A题:Rescue The Princess
http://acm.sdibt.edu.cn/JudgeOnline/problem.php?id=3230
Description
Several days ago, a beast caught a beautiful princess and the princess was put in prison. To rescue the princess, a prince who wanted to marry the princess set out immediately. Yet, the beast set a maze. Only if the prince find out the maze’s exit can he save the princess.
Input
The first line is an integer T(1 <= T <= 100) which is the number of test cases. T test cases follow. Each test case contains two coordinates A(x1,y1) and B(x2,y2), described by four floating-point numbers x1, y1, x2, y2 ( |x1|, |y1|, |x2|, |y2| <= 1000.0).
Output
For each test case, you should output the coordinate of C(x3,y3), the result should be rounded to 2 decimal places in a line.
Sample Input
4
-100.00 0.00 0.00 0.00
0.00 0.00 0.00 100.00
0.00 0.00 100.00 100.00
1.00 0.00 1.866 0.50
Sample Output
(-50.00,86.60)
(-86.60,50.00)
(-36.60,136.60)
(1.00,1.00)
题意:给出A与B的坐标,要求从A到B逆时针转动位置找到一个C点,使他们组成一个等边三角形
思路:
1、求已知线段的斜角:tgα=(y1-y2)/(x1-x2)
2、求已知线段的长度:L=√((y1-y2)^2+(x1-x2)^2)
3、求第三点的坐标:
x3=x2+L*cos(α+60);y3=y2+L*sin(α+60)
而且我们可以发现,如果全部以A点为基底的话,那么求出的C点一定全部都是在A->B的逆时针上,还记得训练时本来已经推出这个公式了,但是当时脑筋很死,没有想到这一点,一直在考虑多种情况,结果反而落于下乘了,在这里我要好好反省
#include <stdio.h>
#include <math.h>
const double pi = acos(-1.0);
int main()
{
int t;
double x1,x2,x3,y1,y2,y3,l,at;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
at = atan2(y2-y1,x2-x1);
printf("%lf\n",(y2-y1)/(x2-x1));
printf("%lf\n",at);
l = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
x3 = x1+l*cos(at+pi/3.0);
y3 = y1+l*sin(at+pi/3.0);
printf("(%.2lf,%.2lf)\n",x3,y3);
} return 0;
}
山东省赛A题:Rescue The Princess的更多相关文章
- 2013年山东省赛F题 Mountain Subsequences
2013年山东省赛F题 Mountain Subsequences先说n^2做法,从第1个,(假设当前是第i个)到第i-1个位置上哪些比第i位的小,那也就意味着a[i]可以接在它后面,f1[i]表示从 ...
- HEX SDUT 3896 17年山东省赛D题
HEX SDUT 3896 17年山东省赛D题这个题是从矩形的左下角走到右上角的方案数的变形题,看来我对以前做过的题理解还不是太深,或者是忘了.对于这种题目,直接分析它的性质就完事了.从(1,1)走到 ...
- 山东省第四届ACM程序设计竞赛A题:Rescue The Princess
Description Several days ago, a beast caught a beautiful princess and the princess was put in prison ...
- 山东省赛J题:Contest Print Server
Description In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source c ...
- 2019acm山东省赛C题
传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4115 昨天赛场上只想到了一种情况:最远点一定是在最后一次循环中产生 ...
- zoj 4122 Triangle City 2019山东省赛J题
题目链接 题意: 给出一个无向图,类似三角形的样子,然后给出边的权值,问找一条从第一个点到最后一个点的路径,要求每一条边只能走一次,并且权值和最大,点可以重复走. 思路: 首先观察这个图可以发现,所有 ...
- 第十届山东省赛L题Median(floyd传递闭包)+ poj1975 (昨晚的课程总结错了,什么就出度出度,那应该是叫讨论一个元素与其余的关系)
Median Time Limit: 1 Second Memory Limit: 65536 KB Recall the definition of the median of elements w ...
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
- 计算几何 2013年山东省赛 A Rescue The Princess
题目传送门 /* 已知一向量为(x , y) 则将它旋转θ后的坐标为(x*cosθ- y * sinθ , y*cosθ + x * sinθ) 应用到本题,x变为(xb - xa), y变为(yb ...
随机推荐
- Jquery异步请求数据实例
一.Jquery向aspx页面请求数据 前台页面JS代码: $("#Button1").bind("click", function () { $.ajax({ ...
- php计算时间差/两个时间日期相隔的天数,时,分,秒.
function timediff( $begin_time, $end_time ) { if ( $begin_time < $end_time ) { $starttime = $begi ...
- int*-------int
a=(int)((int*)0 + 4)求a是多少 大家看图应该明白了 十六进制0x00000010转换为十进制就是16
- python之json
import json import requests re = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=成都') re.en ...
- Problem:To Connect with MySQL in Virtual PC Environment
I'm trying to build a 1:n dev environment,with the help of Vsever(just like VMware worked on sever) ...
- STM32学习笔记——定时器中断(向原子哥学习)
定时器中断 STM32 的定时器功能十分强大,有 TIME1 和 TIME8 等高级定时器,也有 TIME2~TIME5 等通用定时器,还有 TIME6 和TIME7 等基本定时器.在本章中,我们将利 ...
- lsmod
http://blog.csdn.net/yuan892173701/article/details/8960607 抽空写下
- Spring MVC 教程,快速入门,深入分析(转载)
作者:赵磊 博客:http://elf8848.iteye.com 下载: Spring的官方下载网址是:http://www.springsource.org/download (本文使用是的 ...
- Arctic Network
poj2349:http://poj.org/problem?id=2349 题意:有卫星电台的城市之间可以任意联络.没有卫星电台的城市只能和距离小于等于D的城市联络.告诉你卫星电台的个数S,让你求最 ...
- Git for Windows安装和基本设置
1.下载地址: http://msysgit.github.io/ 2.下载完成后安装,安装路径自己选择,其他的选项参照下图: 其他的一步一步往下即可,最后Finish完成安装: 3.配置github ...