Race Against Time - CF - Arranging Clock hands given Hour, Minute and Second in same unit

There are 12 × 60 × 60 positions on the clock face that can be occupied by hands and start/finish positions. I want to place all three hands on a clock such that they are all in same unit (second) ie I want to find a position (for each hand) which will be in between 0 to 12 * 60 * 60-1.

This is the position I got after conversion (total there are 60 * 60 * 12 positions):

h=h*3600+m*60+s;//seems fine
m=60*12*m+s;//wrong
s=s*12*60;//wrong

for example: h=6 m=30 s=0
position should be (Hour hand, min hand, sec hand respectively):
6 * 60 * 60 + 30 * 30 + 0
…?
…?

Problem: https://codeforces.com/contest/868/problem/B
Editorial: https://codeforces.com/blog/entry/55046

how?
If you want them relatively in same units on the clock, I think, just make hour=hour*5, and add s/60 to min, and m/60 to hours afterward.

I meant to say positions.

position wise, hour is the only one, that is in range till 12, minutes and seconds are already in the same way(60s). that’s why I think you need to multiply 5 to hours, and add s/60 and m/60 to minutes and hours respectively(to add the little shift in positions).

1 Like

Could you give an example? You are given a time- H:M:S, we have to find position (for all 3 hands) which will be in between 0 to 12 * 60 * 60 - 1

let h:m:s be 3:10:5, then hour is basically at 3*5=15th position, minute is at 10+5/60=10.083th position, hour would be then at 15+10.083/60=15.168th position, so position wise

15.168 : 10.083 : 5

1 Like