## [Simulation] Clock

### Clock

#### Title Description

wls have a watch, current watch point to a certain time.
There are some very important moments, wls want to watch on the reproduction of these times (not required in order to reproduce). We can rotate the second hand clockwise, counterclockwise rotation can be second hand, minute and hour hands will rotate with the second hand by the rules, wls like to know what the angle of rotation of the second hand at least each time will be visited at least once.
Note that a combination of the minute hand on the clock hour of the second hand, can represent two different times.

#### Entry

The first line an integer n represents the number of time you want to access.
The second line three integers h, m, s respectively represent the current time of minutes and seconds.
N the last line of each row represents three integers hi, mi, si each time you want to access the minutes and seconds.
1≤n≤86,400
0 ≤ h, Hi <24
0 ≦ m, mi The, S, Si <60

#### Export

Output line a second number represents the angle of rotation, the answer to two decimal places.

### Sample input

```1
0 1 0
0 1 1```

#### Sample Output

`6.00`

I put this ring copied three, to each moment as every point on the ring, the ring expands to three.

Three cases:

1, all in the clockwise or counter-clockwise to the full.

2, first go clockwise, counterclockwise go down.

3, first go counter-clockwise, and then further clockwise.  ``` 1 #include<bits/stdc++.h>
2 using namespace std;
3 const int N = 3e5+10;
4 const int M = 43200 ;
5 int a[N],n;
6 int main()
7 {
8
9     //cout << -1 % 10 << endl ;
10     ios_base :: sync_with_stdio(false);
11     cin.tie(NULL) , cout.tie(NULL);
12     int h , mi , s ;
13     cin >> n ;
14     cin >> h >> mi >> s ;
15     int Start = h * 3600 + mi * 60 + s ;
16     if( Start >= M ) Start -= M ;
17     int m = 0 ;
18
19     //cout << "####" << endl;
20
21     for( int i = 0,u,v,w ; i<n ; i++ ){
22         cin >> u >> v >> w ;
23         int tmp = (u * 3600 + v * 60 + w) ;
24         if( tmp >= M ) tmp -= M ;
25         if( Start == tmp ) continue ;
26         else {
27             a[m++] = tmp ;
28         }
29     }
30
31     sort( a , a + m );
32
33     for( int i = 0 ; i < m ; i++ ){
34         a[i+m] = a[i] + 43200 ;
35         a[i+2*m] = a[i] + 86400 ;
36     }
37     if( m == 0 ){
38         //printf("####\n");
39         printf("0.00\n");
40     }else{
41         int L = m+10 , R = m+10 ;
42         Start += 43200 ;
43         //printf("###\n");
44         for( int i = 0 ; i < 3 * m ; i++ ){
45             if( a[i] < Start && Start < a[i+1] ){
46                 L = i , R = i + 1 ;
47                 break ;
48             }
49         }
50         //printf("( %d , %d ) , a[L] = %d , a[R] = %d \n",L,R,a[L],a[R]);
51
52         //printf("%d , %d \n", L , R ) ;
53         int t1 = (Start-a[L]) >= M ? (Start-a[L]) - M : Start-a[L] ;
54         int t2 = (a[R]-Start) >= M ? (a[R]-Start) - M : a[R]-Start ;
55         //t1 = ( t1 + M ) % M ;
56         //t2 = ( t2 + M ) % M ;
57         //printf("%d\n",M);
58         //printf("%d %d\n",t1,t2) ;
59         //printf("%d %d\n",M - t1 , M - t2 );
60         int ans = min( (M - t1) , (M - t2) );
61         //printf("%d %d - %d = %d , %d - %d = %d \n",ans, Start , a[L] , (Start-a[L]) , a[R] , Start ,  (a[R]-Start) );
62         //printf("%d\n",ans);
63         for( int i = L ; L - m + 1 < i ; i-- ){
64             ans = min( ans , (Start - a[i]) * 2 + a[i+m-1] - Start );
65         }
66         for( int i = R ; i < R + m - 1 ; i++) {
67              years = min (years (a [i] - Start) * 2 + Start - a [i-m + 1 ]);
68          }
69          years = years * 6 ;
70          printf ( " % d.00 \ n " , year);
71      }
72      return  0 ;
73 }```
View Code

### Guess you like

Origin www.cnblogs.com/Osea/p/11569260.html
Recommended
Ranking
Daily