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. 树状数组(Binary Indexed Tree,BIT)

    树状数组(Binary Indexed Tree) 前面几篇文章我们分享的都是关于区间求和问题的几种解决方案,同时也介绍了线段树这样的数据结构,我们从中可以体会到合理解决方案带来的便利,对于大部分区间 ...

  2. day16<集合框架+>

    集合框架(去除ArrayList中重复字符串元素方式) 集合框架(去除ArrayList中重复自定义对象元素) 集合框架(LinkedList的特有功能) 集合框架(栈和队列数据结构) 集合框架(用L ...

  3. SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    "F:\program files (x86)\Python35\python.exe" "F:/program files (x86)/JetBrains/Seleni ...

  4. snmp之GenericAddress

    GenericAddress 注册地址类型,而不是默认的,第一次调用解析(java.lang.String的)方法之前,设置系统属性ADDRESS_TYPES_PROPERTIES. 这个类涉及到了工 ...

  5. jQuery点击按钮实现div的隐藏和显示切换效果

    <script type="text/javascript"> $(function(){ $('#click_event').click(function(){  i ...

  6. ImageSharp一个专注于NetCore平台图像处理的开源项目

    今天大家分享的是一个专注于NetCore平台图像处理的开源项目,老实说为这篇文章取名字想了5分钟,可能是词穷亦或是想更好的表达出这款开源项目的作用:这个项目在图像处理方面有很多功能,如:缩放,裁剪,绘 ...

  7. Java面向对象 IO (二)

     Java面向对象  IO   (二) 知识概要:               (1)字节流概述 (2)字节流复制图片 (3)IO流(读取键盘录入) (4)读取转换流,写入转换流 字节流概述   ...

  8. MVVM框架解析(一)

    花了一点时间看了一下微软开源MVVM代码,受义很多! 从代码整体上看,代码分为四大类, 从图中看不能明白我要表达的意思.显而意见!MainApplicationWindow.xaml是应用程序主窗口( ...

  9. NOIP初赛 之 逻辑运算

    NOIP初赛 之 逻辑运算 逻辑运算先掌握各种运算,注意运算符的级别比较,做题是要细心.在NOIP中一般一题,分值为1.5分. 概念介绍: 非:not  ¬      与:and ∧      或:o ...

  10. Linux命令-基本命令(1)

    1. ll dfdfdfd 2. vi dfffd