-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem199.txt
186 lines (159 loc) · 3.02 KB
/
problem199.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
*create_array gaps 708588 0
*create_array new_gaps 708588 0
*create initial_inner_circle 0.46410161514
*create pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862
*create area_left 0.0
*create area_covered 0.0
*create elem_count 1
*create tmp0 0.0
*create tmp1 0.0
*create tmp2 0.0
*create i 1
*create j 1
*create m 1
*create s 0.0
*create x 0.0
*create k1 0.0
*create k2 0.0
*create k3 0.0
*create k4 0.0
*comment Disable loop limit
*looplimit 0
*set tmp0 initial_inner_circle
*set tmp0 * initial_inner_circle
*set tmp0 * pi
*set tmp0 * 3
*set area_left pi
*set area_left - tmp0
*set gaps[1] initial_inner_circle
*set gaps[2] initial_inner_circle
*set gaps[3] initial_inner_circle
*set elem_count 1
*set j 1
*set area_covered 0.0
*label loop1
*gosub iterate
*set elem_count * 3
*gosub move_array
*set j + 1
*if j <= 10
*goto loop1
*set area_left - area_covered
*set gaps[1] 0
*set gaps[1] - 1
*set gaps[2] initial_inner_circle
*set gaps[3] initial_inner_circle
*set elem_count 1
*set j 1
*set area_covered 0.0
*label loop2
*gosub iterate
*set elem_count * 3
*gosub move_array
*set j + 1
*if j <= 10
*goto loop2
*set tmp0 3
*set tmp0 * area_covered
*set area_left - tmp0
*set area_left / pi
*set area_left * 100000000
*set area_left round(area_left)
*set area_left / 100000000
${area_left}
*finish
*comment Moves from gaps to new_gaps, clobbers i, m, tmp0, tmp1, tmp2, s, x, k1, k2, k3, k4. Adds to area_covered.
*label iterate
*set i 0
*label iterate_loop
*set tmp0 3
*set tmp0 * i
*set k1 1.0
*set tmp0 + 1
*set tmp1 gaps[tmp0]
*set k1 / tmp1
*set k2 1.0
*set tmp0 + 1
*set tmp1 gaps[tmp0]
*set k2 / tmp1
*set k3 1.0
*set tmp0 + 1
*set tmp1 gaps[tmp0]
*set k3 / tmp1
*set k4 k1
*set k4 + k2
*set k4 + k3
*set s k1
*set s * k2
*set tmp0 k2
*set tmp0 * k3
*set s + tmp0
*set tmp0 k1
*set tmp0 * k3
*set s + tmp0
*gosub sqrt
*set x * 2
*set k4 + x
*set tmp0 pi
*set tmp0 / k4
*set tmp0 / k4
*set area_covered + tmp0
*set tmp0 i
*set tmp0 * 9
*set tmp0 + 1
*set new_gaps[tmp0] 1
*set new_gaps[tmp0] / k4
*set tmp0 + 1
*set tmp1 i
*set tmp1 * 3
*set tmp1 + 1
*set new_gaps[tmp0] gaps[tmp1]
*set tmp0 + 1
*set tmp1 + 1
*set new_gaps[tmp0] gaps[tmp1]
*set tmp0 + 1
*set new_gaps[tmp0] 1
*set new_gaps[tmp0] / k4
*set tmp0 + 1
*set new_gaps[tmp0] gaps[tmp1]
*set tmp0 + 1
*set tmp1 + 1
*set new_gaps[tmp0] gaps[tmp1]
*set tmp0 + 1
*set new_gaps[tmp0] 1
*set new_gaps[tmp0] / k4
*set tmp0 + 1
*set new_gaps[tmp0] gaps[tmp1]
*set tmp0 + 1
*set tmp1 - 2
*set new_gaps[tmp0] gaps[tmp1]
*set i + 1
*if i < elem_count
*goto iterate_loop
*return
*comment Takes argument in s, returns in x. Clobbers m and tmp0
*label sqrt
*set x s
*set x / 2
*set m 1
*label sqrt_loop
*set tmp0 s
*set tmp0 / x
*set tmp0 + x
*set tmp0 / 2.0
*set x tmp0
*set m + 1
*if m < 200
*goto sqrt_loop
*return
*comment Takes elem_count. Clobbers m and tmp0. Moves from new_gaps to gaps.
*label move_array
*set m 1
*set tmp0 3
*set tmp0 * elem_count
*label move_array_loop
*set gaps[m] new_gaps[m]
*set m + 1
*if m <= tmp0
*goto move_array_loop
*return