Under construction

Still being built. Things may change

Clock

Time limit0.1sMemory limit1024 MB

Summary
Given a starting time on an analog clock and an elapsed offset, output either the current time or the minute marks the hour hand lies between.
Level

Medium4 of 10

Topics
Math, Implementation, Simulation, Brute force
Solved
No attempts yet

Problem

An analog clock with hands shows h hours and m minutes. The hands move at a constant speed. The dial has marks 0 through 11 for the hours the hour hand points to, and marks 0 through 59 for the minutes the minute hand shows. dh hours and dm minutes pass. Which minute mark does the hour hand point to?

Write a program clock that answers this question and follows the output format described below.

Input

The first line of standard input contains five integers h, m, dh, dm, and c, separated by spaces.

Output

The program writes the following to standard output.

When c=1, it writes the time the clock shows as hours and minutes (two integers separated by one space), the way we usually state the time when asked.

When c=2, the program writes which mark intended for the minute hand the hour hand points to. If the hour hand points exactly at a minute mark, the program writes the @ sign, followed by one space and the value the hour hand points to. When the hour hand does not point exactly at a minute mark but lies between two neighboring marks, the program writes the value of the first mark and, after one space, the value of the second mark in the direction the hand moves.

Constraints

  • 0 ≤ h ≤ 11
  • 0 ≤ m ≤ 59
  • 0 ≤ dh ≤ 999
  • 0 ≤ dm ≤ 59
  • 1 ≤ c ≤ 2

Examples4

  1. Example 1

    Input
    3 10 1 5 1
    
    Expected output
    4 15
    
  2. Example 2

    Input
    2 55 11 12 1
    
    Expected output
    2 7
    
  3. Example 3

    Input
    0 0 3 24 2
    
    Expected output
    @ 17
    
  4. Example 4

    Input
    11 54 83 58 2
    
    Expected output
    59 0