Report on time zone conversion in Bailian 2966

Source: Internet
Author: User
Tags time zones

1. Link: http://poj.grids.cn/practice/2966/

2. Question:

Total time limit:
1000 ms
Memory limit:
65536kB
Description
Until the 19th century, time calibration was a pure local phenomenon. When the sun rises to the highest point in each village, their clock is adjusted to noon. The time of a watch manufacturer's home or village master table is regarded as the official time, and citizens align their watches with the time. Enthusiastic citizens take time-standard tables every week and walk around the streets to show tables for other citizens. When traveling between cities, you need to calibrate the pocket watch when arriving at a new place. However, when the railway is put into use, more and more people frequently exchange over long distances, and time becomes more and more important. In the early days of the railway, the timetable was very confusing. Every so-called stopover time was based on the local time of the dock. Time standardization has become very important for efficient railway operation.
In 1878, Canadian Sir Sanford Fleming proposed to use a global time zone (this proposal was adopted and derived from the concept of global time zones we are using today ), he suggested dividing the world into 24 time zones, each spanning a 15-degree longitude line (because the longitude of the earth is 360 degrees, it is divided into 24 parts, and the longitude is 15 degrees ). Sir Sanford Fleming's approach addresses a global time chaos.
In November 18, 1883, the American railway company used the time proposed by Fleming. An international meridian conference was held in Washington in 1884 to choose a suitable Meridian. The Conference finally selected 0 degrees with Greenwich Mean as the standard. Although the time zone has been determined, the country has not immediately changed their time specifications. In the United States, although many States have started to use the standard time zone by 1895, congress did not force the use of the time specifications set by the meeting until 1918.
Today, each country uses a variant of the Fleming Time zone specification. China spans a total of five Time zones, but uses a unified Time specification, such as Coordinated Universal Time (UTC, greenville time) 8 hours earlier. Russia also supports this time zone specification, although the time and Standard Time Zone used by the entire country are one hour ahead of schedule. Australia uses three time zones. The primary time zone is half an hour ahead of his Fleming standard time zone. Many Middle East countries also use a half-time zone (that is, they do not follow the 24 integer time zones of Fleming ).
Because the time zone is used to divide the longitude, scientists who work in the south pole or the North Pole use the UTC time directly. Otherwise, the South Pole will be divided into 24 time zones.
The time zone conversion table is as follows:
UTC Coordinated Universal Time
GMT Greenwich Mean Time, defined as UTC
BST briish Summer Time, defined as UTC + 1 hour
IST Irish Summer Time, defined as UTC + 1 hour
WET Western Europe Time, defined as UTC
WEST Western Europe Summer Time, defined as UTC + 1 hour
CET Central Europe Time, defined as UTC + 1
CEST Central Europe Summer Time, defined as UTC + 2
EET Eastern Europe Time, defined as UTC + 2
EEST Eastern Europe Summer Time, defined as UTC + 3
The definition of the Time of the MSK Moscow is UTC + 3.
MSD Moscow Summer Time, defined as UTC + 4
AST Atlanta Standard Time, defined as UTC-4 hours
ADT Atlanta Daylight Time, defined as UTC-3 hours
NST Newfoundland Standard Time, defined as UTC-3.5 hours
NDT Newfoundland Daylight Time, defined as UTC-2.5 hours
EST Eastern Standard Time, defined as UTC-5 hours
EDT Eastern Daylight Saving Time, defined as UTC-4 hours
CST Central Standard Time, defined as UTC-6 hours
CDT Central Daylight Saving Time, defined as UTC-5 hours
MST Mountain Standard Time, defined as UTC-7 hours
MDT Mountain Daylight Saving Time, defined as UTC-6 hours
PST Pacific Standard Time, defined as UTC-8 hours
PDT Pacific Daylight Saving Time, defined as UTC-7 hours
HST Hawaiian Standard Time, defined as UTC-10 hours
AKST Alaska Standard Time, defined as UTC-9 hours
AKDT Alaska Standard Daylight Saving Time, defined as UTC-8 hours
AEST specified Alian Eastern Standard Time, defined as UTC + 10 hours
AEDT extends Alian Eastern Daylight Time, defined as UTC + 11 hours
ACST extends Alian Central Standard Time, defined as UTC + 9.5 hours
ACDT clock Alian Central Daylight Time, defined as UTC + 10.5 hours
AWST specified Alian Western Standard Time, defined as UTC + 8 hours
The following provides some time for conversion between different time zones.
Input
The first line of the input contains an integer N, indicating that there are N groups of test data. In the next N rows, each row contains an abbreviation of time and two time zones, which are separated by spaces. The time is given by standard a.m./p.m. Midnight indicates a.m., and noon indicates p.m .).
Output
If the time given by the input line is the standard time in the first time zone, the standard time of the time in the second time zone must be output.
Sample Input
4noon HST CEST 11:29 a.m. EST GMT6:01 p.m. CST UTC12:40 p.m. ADT MSK
Sample output
midnight4:29 p.m.12:01 a.m.6:40 p.m.

3. Code:

 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring>      zone[][] = {,,,,,                     ,,,,                     ,,,,                     ,,,,                     ,,,,                     ,,,,                        m_time[] = {,,,,,,,,,,,,-,-,-,-,-,-,-,-,-                     -,-,-,-,-,-,,,,,             cin>>            chs[                ch1[],zone1[],zone2[     (n--           (chs[] ==               sscanf(chs,             thour =              tminute =            (chs[] ==               sscanf(chs,             thour =              tminute =                         sscanf(chs,,&thour,&                                 thour %=              (ch1[] == ) thour +=                    minute = thour *  +                           ( i = ; i < ; i++              (!strcmp(zone[i],zone1)) m_idx1 =             (!strcmp(zone[i],zone2)) m_idx2 =          diff_zone = m_time[m_idx2] -         minute += ()(diff_zone *                   (minute < ) minute +=          minute %=                   thour = minute /          tminute = minute %                   (thour ==  && tminute == ) printf(          (thour == ) printf(          (thour < ) printf(          (thour ==  && tminute == ) printf(          (thour == ) printf(          printf(,thour-             }

4. Ideas:

(1) An error occurred N times

(2) Pay attention to the time representation of this question. For example, 00:01 a.m. refers to A.M! Pay attention to this.

(3) It can be converted to minutes before calculation, which saves a lot of trouble.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.