poj 1254 Hansel and Grethel
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 2199 | Accepted: 1004 |
Description
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 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
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,°1);
scanf("%d%d%d",&x2,&y2,°2);
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的更多相关文章
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目分类(转)
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- POJ题目(转)
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法: (1)枚举. (poj1753,poj29 ...
- [POJ题目分类][转]
Hint:补补基础... 初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治 ...
随机推荐
- ui-router
学习历程:1 ng-router --> 2 location --> 3 $location --> 4 promise --> 5 html5 history -- ...
- [Java语言] 《struts2和spring MVC》的区别_动力节点
1.Struts2是类级别的拦截, 一个类对应一个request上下文,SpringMVC是方法级别的拦截,一个方法对应一个request上下文,而方法同时又跟一个url对应,所以说从架构本身上Spr ...
- 【转】 IntelliJ IDEA像Eclipse一样打开多个项目
http://blog.csdn.net/zht666/article/details/47831893 我们做项目实际中经常会遇到这样的情况,创建一个common项目(Maven项目)作为公用项目, ...
- MySQL innodb引擎下根据.frm和.ibd文件恢复表结构和数据
记录通过.frm和.ibd文件恢复数据到本地 .frm文件:保存了每个表的元数据,包括表结构的定义等: .ibd文件:InnoDB引擎开启了独立表空间(my.ini中配置innodb_file_per ...
- 一文为你详细讲解对象映射库【AutoMapper】所支持场景
前言 在AutoMapper未出世前,对象与对象之间的映射,我们只能通过手动为每个属性一一赋值,时间长了不仅是我们而且老外也觉得映射代码很无聊啊.这个时候老外的所写的强大映射库AutoMapper横空 ...
- 如何修改select标签的默认下拉箭头样式?
对于一般的项目而言,select标签在浏览器中表现出来的默认样式也不算丑,但是一次项目中,项目经理却要求对select标签本身进行样式修改,美化其下拉小箭头的样式.我思考和尝试了许多方法,最终得到一种 ...
- Vue使用总结
好久没更新博客,确实是自己已经懒癌晚期,最近毕业刚工作3个月,公司开发一直在用Vue,自己个人也比较喜欢这个框架,今天就对自己学习到和用到的知识点作一些总结,希望能帮到大家. Vue 知道Vue也一定 ...
- Redis缓存项目应用架构设计二
一.概述 由于架构设计一里面如果多平台公用相同Key的缓存更改配置后需要多平台上传最新的缓存配置文件来更新,比较麻烦,更新了架构设计二实现了缓存配置的集中管理,不过这样有有了过于中心化的问题,后续在看 ...
- sql server 2000的安装
一.安装sql 二.启动sql 三.查看sql版本 RTM版本,需要打补丁 四.安装SP4
- JavaScript链式调用
1.什么是链式调用? 这个很容易理解,例如 $('text').setStyle('color', 'red').show(); 一般的函数调用和链式调用的区别:链式调用完方法后,return thi ...