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 }