The return of el campanar de la Torrassa

[image]

El Campanar de la Torrassa is well known for annoying its neighbors with
the sound of its bells. Recently, this church run short of money, so the
bell with the bass sound was sold. Now, with just one bell, the priest
devised a new scheme. Every hour, the bell sounds as many times as the
hour (from once to twelve times). Also, the bell sounds once at one
quarter, again at two quarters, and again at three quarters.

The priest is happy to inform the neighbors that now bells sound lesser
times than in the past. For instance, if some lady wakes up in the
middle of the night, say at 3:18, she will hear the bell once at 3:30,
once at 3:45, and four times at 4:00. Observe that had she has to wait
for 42 minutes to exactly know what time it is. Moreover, she hears six
bell sounds. (For comparison, with the traditional scheme, the bell
sounds thirteen times.)

Write a program to compute the number of minutes that someone who wakes
up at h:m has to wait to exactly know the current time (plus/minus
twelve hours), and also how many bell sounds he or she hears in the
meantime.

Input

Input consists of several cases, each with two integer numbers h and m.
Assume 0 ≤ h ≤ 23 and 0 ≤ m ≤ 59.

Output

For every case, print the number of minutes that someone who wakes up at
h:m has to wait to exactly know what time it is, and the number of times
that the bells sound during this lapse of time.

Problem information

Author: Jordi Petit

Generation: 2026-01-25T11:31:25.644Z

© Jutge.org, 2006–2026.
https://jutge.org
