CLOCK:Author: Tushar Kadam Tester: Sangram Desai Editorialist: Tushar Kadam DIFFICULTY:SIMPLE PREREQUISITES:
PROBLEM:Given time in HH MM SS format and you have to find what will be time after hour hand moves by x degrees. EXPLANATION:If hour hand moves by 1 degree then 2 minutes will happen in 12 hour clock. As x is integer and smallest change in x can be only 1 degree hence second hand will come to its original position whatever may be the value of x i.e SS field will not change. Now find if minutes to add in MM field is greater than 60 or not . If final MM field > 60 then add extra minutes in hour by converting minutes to hour. Note : if x > 360 that means hour hand has moved by more than 360 degrees i.e several complete rotations have happened. so to solve one can do x = x%360 which will have same effect. Possible testcases where you may get wrong answers: input : 6 11 58 59 1 11 59 1 1 12 58 55 28 11 2 23 29 11 2 0 361 11 59 27 62 output: 12 0 59 12 1 1 1 54 55 12 0 23 11 4 0 2 3 27 AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution Java Solution Tester's solution Python Solution.
This question is marked "community wiki".
asked 09 Sep, 14:22

The preliminary step here is to find out what $1$ degree motion of the hour hand means in terms of time. 0ne full rotation of the hour hand is $12$ hours or $12\times 60 = 720$ minutes, and conveniently we have $720/360 = 2$ exactly; giving $2$ minutes per degree. If, instead of degrees, the question had asked the time after the hour hand is moved by $x$ gradians, which have $400$ for a full turn, we would have had to go down to an effect in seconds, with $720\times 60 = 43200$ second in a full turn of the hour hand and thus $108$ seconds per gradian. answered 13 Sep, 02:43
@joffan Thanks for your suggestion about use of gradians in problem . But I wanted to design an easy problem So I deliberately made a special case in which that it turns out that 1 degree corresponds to 2 minutes. So bonus question : x can be negative
(13 Sep, 23:43)
1
Oh sure, I wasn't complaining at all about the use of degrees. Just pointing out where the 1 degree = 2 minutes comes from. And my alternative example was gradians not radians  they would be much more difficult since a full turn in radians is $2\pi$. PS: re bonus question: my code already worked correctly. :)
(13 Sep, 23:51)
Oh my bad! Edited! And I just saw your code.
(14 Sep, 00:09)

include <stdio.h>include<time.h>long t,x[100000]; int hr[100000],min[100000],sec[100000]; void calc(){ long m=0,min_angle,hr_angle,sec_angle; while(m<t){ if(x[m]%30="=0){" x[m]="x[m]/30;" if(x[m]="">12){ while(x[m]>12){ x[m]=x[m]12; } } hr[m]=x[m]+hr[m]; if(hr[m]>12){ hr[m]=hr[m]12; } } else{ if(x[m]<30){ min_angle=x[m]; hr_angle=0; } else{ min_angle=x[m]%30; hr_angle=x[m]/30; } if(hr_angle>12){ while(hr_angle>12){ hr_angle=hr_angle12; } } hr[m]=hr[m]+hr_angle; if((min_angle2+min[m])>=60){ hr[m]=hr[m]+1; min[m]=(min[m]+(min_angle2))60; } else{ min[m]=min[m]+min_angle*2; } if(hr[m]>12){ hr[m]=hr[m]12; } } m++; } } int main(void) { scanf("%lu",&t); for(long i=0;i<t;i++){ scanf("%d%d%d%li",&hr[i],&min[i],&sec[i],&x[i]); } calc(); for(long m=0;m<t;m++){ printf("%d %d %d\n",hr[m],min[m],sec[m]); } return 0; } answered 12 Sep, 21:22
