1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4 using namespace std;
5
6 double T = 43200;
7 double D;
8
9 struct Insect {
10
11 double x, y;
12 }in[ 3 ];
13
14 vector<Insect> V[ 4 ];
15 //求秒针,分针,时针的时间段的交集
16 //这里先求秒针,分针的时间段的交集, 然后这个求出的交集再和时针的时间段求交集
17 void solved(vector<Insect> v1, vector<Insect> v2) {
18
19 vector<Insect> vv;
20 int n = v1.size(), m = v2.size();
21 int i = 0, j = 0;
22 while(i < n && j < m) {
23
24 Insect p, q, r;
25 p = v1[ i ];
26 q = v2[ j ];
27
28 if(p.x <= q.x) {
29
30 if(p.y > q.x) {
31
32 r.x = q.x;
33 if(q.y > p.y) {
34
35 r.y = p.y;
36 i ++;
37 }
38 else {
39
40 r.y = q.y;
41 j ++;
42 }
43 vv.push_back(r);
44 }
45 else {
46
47 i ++;
48 }
49 }
50 else {
51
52 if(q.y > p.x) {
53
54 r.x = p.x;
55 if(q.y > p.y) {
56
57 r.y = p.y;
58 i ++;
59 }
60 else {
61
62 r.y = q.y;
63 j ++;
64 }
65 vv.push_back(r);
66 }
67 else {
68
69 j ++;
70 }
71 }
72 }
73 V[ 3 ] = vv;
74 }
75
76 //分别求出秒针,分针,时针,相互之间角度>=D的时间段
77 //秒针和分针角度>=D 可能的时间段为 (10D+3600k)/59<=t<=(3600+3600k-10D)/59
78 //秒针和时针角度>=D 可能的时间段为 (120D+43200k)/719<=t<=(43200+43200k-120D)/719
79 //分针和时针角度>=D 可能的时间段为 (120D+43200k)/11<=t<=(43200+43200k-120D)/11
80 void terminal() {
81
82 double cnt = 0;
83 for(int i = 0; i < 4; ++ i) V[ i ].clear();
84 for(int k = 0; k <= 1000; ++ k) {
85
86 in[ 0 ].x = (10.0*D+3600.0*k) / 59.0;
87 in[ 0 ].y = (3600.0+3600.0*k-10.0*D) / 59.0;
88
89 in[ 1 ].x = (120.0*D+43200.0*k) / 719.0;
90 in[ 1 ].y = (43200.0+43200.0*k-120.0*D) / 719.0;
91
92 in[ 2 ].x = (120.0*D+43200*k) / 11.0;
93 in[ 2 ].y = (43200.0+43200.0*k-120.0*D) / 11.0;
94
95 if(in[ 0 ].x <= T) {
96
97 if(in[ 0 ].y > T) in[ 0 ].y = T;
98 V[ 0 ].push_back(in[ 0 ]);
99 }
100
101 if(in[ 1 ].x <= T) {
102
103 if(in[ 1 ].y > T) in[ 1 ].y = T;
104 V[ 1 ].push_back(in[ 1 ]);
105 }
106
107 if(in[ 2 ].x <= T) {
108
109 if(in[ 2 ].y > T) in[ 2 ].y = T;
110 V[ 2 ].push_back(in[ 2 ]);
111 }
112 }
113 solved(V[ 0 ], V[ 1 ]);
114 solved(V[ 2 ], V[ 3 ]);
115 for(int j = 0; j < V[ 3 ].size(); ++ j) {
116
117 Insect p = V[ 3 ][ j ];
118 cnt += p.y - p.x;
119 }
120 printf("%.3lf\n", cnt*100.0/T);
121 }
122
123 int main() {
124
125 while(~scanf("%lf", &D)) {
126
127 if(D < 0) break;
128 terminal();
129 }
130 return 0;
131 }