山东省赛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 ...
随机推荐
- filter过滤器执行顺序
浏览器请求---->进入过滤器---->进入doFilter方法--->执行chain.doFilter()方法就会放行----->进入业务逻辑方法------>进入过滤 ...
- 从windows到Linux-ubuntu新手
版本选择: 经多次实验,Ubuntu个人认为长期支持(LTS)版才值得装. VMware9中测试:Ubuntu10.04开机内存170M,Ubuntu12.04开机内存340M. 个人感觉Ubuntu ...
- 浅谈dataGridView使用,以及画面布局使用属性,对datagridview进行增删改查操作,以及委托使用技巧
通过几天的努力后,对datagridview使用作一些简要的介绍,该实例主要运用与通过对datagridview操作.对数据进行增删改查操作时,进行逻辑判断执行相关操作.简单的使用委托功能,实 ...
- dedecms 修改标题长度可以修改数据库
数据表为dede__archives 字段为title 首先要在 a.系统->系统基本参数->其它选项->文章标题长度 b.系统->SQL命令行工具 alter table # ...
- shell 脚本中 命令
终端工具tput和stty是两款终端处理工具tput cols,lines,longname,cpu 100 100 输入密码时,不能让输入的内容显示出来.用stty #!/bin/bash #Fil ...
- 安装search everything中文语言包
Everything 作为很多人的必备工具,特写这篇文章,一方面让想使用国外优秀软件的英语小白有一段过渡期,另一方面也为自己整理下资料.当然,这个可不是不学好英语的正当理由. 步骤: 1. 下载好se ...
- HTML用法小摘录
一.网页地址栏上小图标标签添加写法: <link rel="Shortcut Icon" href="~/Content/ico/glasses.ico" ...
- intent.addFlags
一.Activity和Task(栈)的关系 Task就像一个容器,而Activity就相当与填充这个容器的东西,第一个东西(Activity)则会处于最下面,最后添加的东西(Activity)则会在 ...
- 支付宝集成获取私钥与公钥-b
项目需要,需要在客户端集成支付宝接口.就研究了一下:因为使用支付宝接口,就需要到支付宝官网:注册帐号,并申请.下面讲的是申请好之后的操作.登录成功之后, 店家我的商家服务—在页面的下方找到——&g ...
- 求助:对话框下OnInitDialog中使用SetTimer无效
原文地址:http://www.w3c.com.cn/%E6%B1%82%E5%8A%A9%EF%BC%9A%E5%AF%B9%E8%AF%9D%E6%A1%86%E4%B8%8Boninitdial ...