Hansel and Grethel
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 2199   Accepted: 1004

Description

On a warm summer afternoon, Hansel and Grethel are walking together in the fields. It is getting late and, to be honest, they are lost. Grethel is a little scared, still vividly remembering the last time they got lost in the forest. That time, an evil witch had locked them inside a house built of gingerbread and sugar! But Hansel can reassure her: this time they are well prepared. Hansel has taken a map and a compass with him! 
Hansel picks two clearly outstanding features in the landscape, and uses the compass to measure the direction towards both objects. Grethel locates the objects on the map, and writes down the corresponding map coordinates. Based on this information, they will be able to accurately determine their own position on the map. 

The coordinates of two marker objects, and the direction (angle from the North) towards these objects are known. Write a program which uses this data to calculate the coordinates of Hansel and Grethel’s current location. 

Input

The first line of the input contains one positive number: the number of situations in which a position must be determined. Following are two lines per situation, describing the two marker objects. Each marker object is described by a line containing three integer numbers: 
the x-coordinate of the object on the map (0 <= x <= 100); 
the x-axis runs West-to-East on the map, with increasing values towards the East. 
the y-coordinate of the object on the map (0 <= y <= 100); 
the y-axis runs South-to-North on the map, with increasing values towards the North. 
the direction d of the object in degrees (0 <= d <= 360); 
with 0 degree = North, 90 degree = East, 180 degree = South, and so on. 
To keep the position calculations accurate, Hansel makes sure that the directions of the two 
objects are not exactly equal, and do not differ by exactly 180 degree.

Output

One line per situation, containing the result of the position calculation: two numbers, separated by a space, each having exactly 4 digits after the decimal point. These numbers represent the x and y coordinates of the position of Hansel and Grethel (0 <= x,y <= 100). Round the numbers as usual: up if the next digit would be >= 5, down otherwise. 

Sample Input

2
30 50 90
20 40 180
30 40 96
20 20 150

Sample Output

20.0000 50.0000
7.0610 42.4110

Source

/*
* @Author: Lyucheng
* @Date: 2017-08-06 10:53:59
* @Last Modified by: Lyucheng
* @Last Modified time: 2017-08-06 22:23:41
*/
/*
题意:给你两个相对于一点的方向和坐标,让你求这点的坐标 思路:就是求两个直线的交点
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h> #define PI 3.141592653589793238 using namespace std; int n;
double x,y;
int x1,x2,y1,y2;
double K1,K2;
int deg1,deg2; double Change(int deg){
return (double)( ( (-deg)% )*1.0 );
} int main(){
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d",&n);
while(n--){
scanf("%d%d%d",&x1,&y1,&deg1);
scanf("%d%d%d",&x2,&y2,&deg2);
K1=tan(Change(deg1)/*PI);
K2=tan(Change(deg2)/*PI);
x=(y2-y1-x2*K2+x1*K1)/(K1-K2);
y=((x2-x1)*K1*K2+y1*K2-y2*K1)/(K2-K1);
printf("%.4f %.4f\n",x,y);
}
return ;
}

poj 1254 Hansel and Grethel的更多相关文章

  1. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  2. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  3. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  4. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  5. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

  6. POJ题目分类(转)

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  7. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  8. POJ题目(转)

    http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj29 ...

  9. [POJ题目分类][转]

    Hint:补补基础... 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治 ...

随机推荐

  1. 中位数的和_KEY

    中位数的和 (number.pas/c/cpp) [题目描述] flower 有 N-1 个朋友,他们要一起玩一个游戏:首先确定三个非负整数 a,b,c,然后每个人依次在纸上写一个数,设第 i 个人写 ...

  2. Day4 装饰器——迭代器——生成器

    一 装饰器 1.1 函数对象 一 函数是第一类对象,即函数可以当作数据传递 #1 可以被引用 #2 可以当作参数传递 #3 返回值可以是函数 #3 可以当作容器类型的元素 二 利用该特性,优雅的取代多 ...

  3. 微信小程序-发送模板消息(C#)

    步骤一:获取模板ID 有两个方法可以获取模版ID 通过模版消息管理接口获取模版ID 在微信公众平台手动配置获取模版ID 步骤二:页面的 <form/> 组件,属性report-submit ...

  4. Navicat for MySQL:快捷键整理

    使用快捷键,提升工作效率! ctrl+q 打开查询窗口 ctrl+/ 注释sql语句 ctrl+shift +/ 解除注释 ctrl+r 运行查询窗口的sql语句 ctrl+shift+r 只运行选中 ...

  5. 初识Hibernate之理解持久化类

         上一篇文章我们简单介绍了Hibernate相关的一些最基本的文件及其作用,并在最后完整的搭建了Hibernate的运行环境,成功的完成了与数据库的映射.但是至于其中的一些更加细节的地方并没有 ...

  6. jvm系列(四):jvm知识点总结

    原文链接:http://www.cnblogs.com/ityouknow/p/6482464.html jvm 总体梳理 jvm体系总体分四大块: 类的加载机制 jvm内存结构 GC算法 垃圾回收 ...

  7. Java Socket通信以及可能出现的问题解决

    Java中基于TCP协议实现网络通信的两个类:客户端的Socket和服务器端的ServerSocket. Socket通信模型如图所示: 不管Socket通信的功能有多复杂,任何socket通信过程的 ...

  8. IP报文分片

    1. 最大传输单元(Maximum Transmission Unit,MTU). 以太网帧中的数据长度规定最小46 字节,最大1500 字节,MTU 指数据帧中有效载荷的最大长度,不包括帧首部的长度 ...

  9. Chloe.ORM框架应用实践

    Chloe.ORM 是国人开发的一款数据库访问组件,很是简单易用.目前支持四种主流数据库:SqlServer.MySQL.Oracle,以及Sqlite,作者为这四种数据库划分出了各自对应的组件程序集 ...

  10. Swift搭建服务端

    原文:Hello Server Side Swift 作者:Logan Wright 译者:CocoaChina--kmyhy(博客) 自从苹果官方发布了一个 Swift 的 Linux 开源版本之后 ...