ural 1341. Device

1341. Device

Time limit: 1.0 second
Memory limit: 64 MB

Major (M): You claimed that your device would be able to fly round the Earth several times and to miss not more than a couple of centimeters?

Designer (D); Yes! Our gravitational fields system of navigation absolutely...

M: Furthermore it can’t be fixed by detectors and doesn’t have a receiver or transmitter.

Engineer (E): It was your demand that nobody could detect the device...

M: We gave it a simple task to fly round the square. It didn’t return to the initial point.

D: Was that square large?

M: It’s none of your business! This is the State secret! You are to find the device!

Programmer (P): How did you programme the mission profile?

M: The device was to fly one conditional length unit to the North, the same distance to the East, the same distance to the South and then to the West. It passed more than 40 minutes since the device was to return. If they find it before us!.. In short, you are to find it!

D: It’s understood. Where was the initial point?

(The major flags and in two seconds the designer lies on the floor with his hands tied and two gunpoints look at his nape).

M: Why do you need this information?

E: You misunderstood! We don’t need information! But if we knew the initial point coordinates we could say where the device was...

(In two seconds two gunpoints look at the engineer’ nape, too).

M: Who interests this information? Where is the device? One, two, ...

P: You can’t understand! If the device reached the North Pole it can’t continue not to the North. Not to the East. Only to the South! Where the device is depends on where it started.

(Major aims at the programmer.)

M: No, it didn’t reach the Pole. It was taken into account.

P: Let me write a program that would count the final coordinates of the device. You’ll input the latitude, the longitude and the value of your conditional length unit yourself! The program would give you the answer keeping the absolute secrecy.

M: I’ll give you a chance. You three have got a computer and five hours... Less than five hours already. If we do not get the coordinates... You’ll suffer first.

Input

The first line contains the initial latitude W. –90 < W < 90. The second line – the initial longitude L, -180 < L ≤ 180. The third line contains the length of the square side, which the device was to fly round. The length is given in kilometers. The device keeps the fixed distance 6400 km from the Earth center of mass. The South Pole has latitude –90, the North Pole – latitude 90. The East direction is counted off the 0th meridian in the positive direction.

Output

You should output the final latitude and longitude of the device within three digits after a decimal point.

Sample

input output
56.846841
53.36673
1124.427
56.847
60.631

Problem Author: Stanislav Vasilyev
Problem Source: USU Championship 2004

Tags: geometry  (hide tags for unsolved problems)

Difficulty: 1115

题意:地球(R=6400km)表面有一个飞行器,先往北飞,再往东飞,再往南飞,再往西飞,都飞相同距离l。

给定这个小东西的起始经纬度(北正南负东正西负),求飞完之后的经纬度。

分析:

造成误差的原因是因为改变纬度后,所对应的圆的半径改变,造成相同距离而却有不同的经度变化。

那么算出各自的经度变化再相减就好。

我傻逼,一开始居然没想到怎么造成误差。

果然是数学喳喳。

 1 /**
 2 Create By yzx - stupidboy
 3 */
 4 #include <cstdio>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <cmath>
 8 #include <deque>
 9 #include <vector>
10 #include <queue>
11 #include <iostream>
12 #include <algorithm>
13 #include <map>
14 #include <set>
15 #include <ctime>
16 #include <iomanip>
17 using namespace std;
18 typedef long long LL;
19 typedef double DB;
20 #define For(i, s, t) for(int i = (s); i <= (t); i++)
21 #define Ford(i, s, t) for(int i = (s); i >= (t); i--)
22 #define Rep(i, t) for(int i = (0); i < (t); i++)
23 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
24 #define rep(i, x, t) for(int i = (x); i < (t); i++)
25 #define MIT (2147483647)
26 #define INF (1000000001)
27 #define MLL (1000000000000000001LL)
28 #define sz(x) ((int) (x).size())
29 #define clr(x, y) memset(x, y, sizeof(x))
30 #define puf push_front
31 #define pub push_back
32 #define pof pop_front
33 #define pob pop_back
34 #define ft first
35 #define sd second
36 #define mk make_pair
37 inline void SetIO(string Name)
38 {
39     string Input = Name+".in",
40     Output = Name+".out";
41     freopen(Input.c_str(), "r", stdin),
42     freopen(Output.c_str(), "w", stdout);
43 }
44
45
46 inline int Getint()
47 {
48     int Ret = 0;
49     char Ch = ‘ ‘;
50     bool Flag = 0;
51     while(!(Ch >= ‘0‘ && Ch <= ‘9‘))
52     {
53         if(Ch == ‘-‘) Flag ^= 1;
54         Ch = getchar();
55     }
56     while(Ch >= ‘0‘ && Ch <= ‘9‘)
57     {
58         Ret = Ret * 10 + Ch - ‘0‘;
59         Ch = getchar();
60     }
61     return Flag ? -Ret : Ret;
62 }
63
64 const DB Pi = acos(-1.0), R = 6400.0;
65 DB Latitude, Longitude, Length;
66
67 inline void Input()
68 {
69     cin >> Latitude >> Longitude >> Length;
70 }
71
72 inline void Solve()
73 {
74     DB Delta =
75         Length / (R * cos(Latitude / 180 * Pi+ Length / R)) -
76         Length / (R * cos(Latitude / 180 * Pi));
77     Delta = Delta / (2 * Pi) * 360;
78     Longitude += Delta;
79     while(Longitude > 180.0) Longitude -= 360.0;
80     while(Longitude <= -180.0) Longitude += 360.0;
81     printf("%.3lf\n%.3lf\n", Latitude, Longitude);
82 }
83
84 int main()
85 {
86     #ifndef ONLINE_JUDGE
87     SetIO("D");
88     #endif
89     Input();
90     Solve();
91     return 0;
92 }

时间: 2024-10-10 10:58:20

ural 1341. Device的相关文章

URAL 1900. Brainwashing Device(dp+输出路径)

1900. Brainwashing Device Time limit: 1.0 second Memory limit: 64 MB While some people travel in space from planet to planet and discover new worlds, the others who live on Earth still have to get up in the morning, go to work, return back home and t

ural 2062 Ambitious Experiment

2062. Ambitious Experiment Time limit: 3.0 secondMemory limit: 128 MB During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity

java.io.IOException: No space left on device 错误

今天碰到比较奇怪的问题: 7/05/14 19:20:24 INFO util.Utils: Fetching http://192.168.31.160:33039/jars/spark_study_java-0.0.1-SNAPSHOT-jar-with-dependencies.jar to /tmp/spark-446068a4-aaa4-4277-b009-908bf0d4ecac/executor-dcc3175b-7d19-4485-81e1-bf31a83a66b4/spark-

linux 6.x network device not active

[[email protected] Desktop]# service networkrestart Shutting down interface eth0: Error: Device\'eth0\' (/org/freedesktop/NetworkManager/Devices/0)disconnecting failed: This device is not active [FAILED] Shutting down loopback interface: [ OK ] Bring

HoloLens开发手记 - 使用Windows设备控制台 Using Windows Device Portal

Windows设备控制台允许你通过Wi-Fi或USB来远程控制你的HoloLens设备.设备控制台是HoloLens上的一个Web Server,你可以通过PC的浏览器来连接到它.设备控制台包含了很多帮助你管理.调试和优化HoloLens设备的工具. 设置HoloLens以使用Windows设备控制台 Setting up HoloLens to use Windows Device Portal 打开HoloLens,并穿戴上 使用绽开手势打开开始菜单 选中设置应用,在你放置它以后会自动启动

USB device &amp; USB controller &amp; USB passthrough

近期往 openstack 里倒腾 USB passthrough[1],遂把 USB 知识做较为全面的整理,以供分享. USB device 什么是 USB device, 上图机智的小萌狗就是 USB device,你的鼠标是 USB device, 键盘是 USB device,U 盘更是典型的 USB device.说了这么多例子,还是得用一个专业的名词一语概之,所谓 USB,即是 Universal Serial Bus(通用串行总线),它是用来连接 USB device 和计算机,从

Ural 1081 Binary Lexicographic Sequence(DP)

题目地址:Ural 1081 先用dp求出每个长度下的合法序列(开头为1)的个数.然后求前缀和.会发现正好是一个斐波那契数列.然后每次判断是否大于此时长度下的最少个数,若大于,说明这一位肯定是1,若小于,则肯定是0.就这样不断输出出来即可. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #in

URAL 1684. Jack&#39;s Last Word KMP

题目来源:URAL 1684. Jack's Last Word 题意:输入a b 把b分成若干段 每一段都是a的前缀 思路:b为主串 然后用a匹配b 记录到b的i位置最大匹配的长度 然后分割 分割的时候要从后往前 如果a = abac b = abab 那么如果从前往后 首先覆盖了aba 然后b就不能覆盖了 从后往前就可以了 首先覆盖ab 下一次还是ab 因为已经记录了到i位置的最大匹配长度 根据长度从末尾倒退 每次倒退的时候只要是最大的匹配的长度 因为如果在某一次的递推 记录的最大匹配的前缀

Ceph安装QEMU报错:User requested feature rados block device configure was not able to find it

CentOS6.3中,要想使用Ceph的block device,需要安装更高版本的QEMU. 安装好ceph后,安装qemu-1.5.2 # tar -xjvf qemu-1.5.2.tar.bz2 # cd qemu-1.5.2 # ./configure --enable-rbd 一定要加上--enable-rbd选项,这样qemu才能支持rbd协议. 这一步可能会报错: ERROR: User requested feature rados block device configure