Sejong's Time Travel
Time limit1sMemory limit1024 MB
Given the current date and location and a target date and location, print the coordinates to enter, since the machine moves opposite to each entered change.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Sejong, who had just enrolled at Sejong University, had dreamed of time travel since childhood. While studying hard at school, he recently heard a rumor from his friend Hanyang, who attends Hanyang University, that the university had secretly built a time machine!
Sejong ran to the Hanyang University lab where the time machine was kept and found a user manual that said:
- Enter the year, month, and day of the destination.
- Enter the latitude and longitude of the destination, exact to the third decimal place.
- Press the travel button.
As he was about to time travel right after reading the manual, Sejong found a note he had not read yet!
The note said the following.
-
The time machine is not finished yet, so it moves in the opposite direction of the spatio-temporal coordinates entered. This is a serious bug.
-
For time, if the entered time is days after the current time, the machine moves days before. If the entered time is days before, the machine moves days after.
-
For latitude, if the entered latitude is north of the current latitude (an increase), the machine actually moves the same distance south (a decrease). If the entered latitude is south of the current latitude (a decrease), the machine actually moves the same distance north (an increase).
- All latitude values are given near South Korea, so you do not need to consider cases where the latitude after moving is less than or greater than .
- In every input and output of this problem, the latitude is guaranteed to be between and , inclusive.
-
For longitude, if the entered longitude is east of the current longitude (an increase), the machine actually moves the same distance west (a decrease). If the entered longitude is west of the current longitude (a decrease), the machine actually moves the same distance east (an increase).
- All longitude values are given near South Korea, so you do not need to consider cases where the longitude after moving is less than or greater than .
- In every input and output of this problem, the longitude is guaranteed to be between and , inclusive.
-
For example, if you start at latitude , longitude and enter latitude , longitude , the machine actually moves you to latitude , longitude .
Given the spatio-temporal coordinates Sejong is currently at and the spatio-temporal coordinates he wants to travel to, compute the coordinates he must enter into the time machine.
For convenience, assume that one year has months and one month has days.
Input
The first line contains the year , month , day , latitude , and longitude of the current time when Sejong boarded the time machine, separated by spaces.
The second line contains the year , month , day , latitude , and longitude of the time Sejong wants to travel to, separated by spaces.
All years, months, and days are given as integers, and all latitudes and longitudes are given exactly to the third decimal place.
No number has unnecessary leading zeros.
Output
Print the year, month, day, latitude, and longitude that Sejong must enter into the time machine on one line, separated by spaces.
Print the year, month, and day as integers, and print the latitude and longitude exactly to the third decimal place.
No number may have unnecessary leading zeros.
Hint
Latitude is the angle that measures how far a point lies north or south of the equator. North is positive and south is negative. The range is from degrees (South Pole) to degrees (North Pole).
Longitude is the angle that measures how far a point lies east or west of the prime meridian (Royal Observatory, Greenwich). East is positive and west is negative. The range is from degrees to degrees.