Форум программистов, компьютерный форум CyberForum.ru

Программа Пентамино - C++

Восстановить пароль Регистрация
 
Рейтинг: Рейтинг темы: голосов - 9, средняя оценка - 4.89
paserge
-3 / 0 / 0
Регистрация: 16.01.2013
Сообщений: 42
13.02.2013, 13:38     Программа Пентамино #1
Я написал рабочий код программы Пентамино, программа находит все решения по размещению 12 фигурок в область 60 клеток. Как ее улучшить работает медленно.

Вот код:
Кликните здесь для просмотра всего текста
C++
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip>
using namespace std; 
int main()
{int x=1;
 
//r
int a[]={28,29,30,39,40,29,30,31,40,41,30,31,32,41,42,31,32,33,42,43,40,41,42,51,52,41,42,43,52,53,42,43,44,53,54,43,44,45,54,55,44,45,46,55,56,52,53,54,63,64,53,54,55,64,65,54,55,56,65,66,55,56,57,66,67,56,57,58,67,68,64,65,66,75,76,65,66,67,76,77,66,67,68,77,78,67,68,69,78,79,68,69,70,79,80,76,77,78,87,88,77,78,79,88,89,78,79,80,89,90,79,80,81,90,91,80,81,82,91,92,88,89,90,99,100,89,90,91,100,101,90,91,92,101,102,91,92,93,102,103,92,93,94,103,104,101,102,103,112,113,102,103,104,113,114,103,104,105,114,115,104,105,106,115,116,28,29,30,42,43,29,30,31,43,44,30,31,32,44,45,31,32,33,45,46,39,40,41,53,54,40,41,42,54,55,41,42,43,55,56,42,43,44,56,57,43,44,45,57,58,51,52,53,65,66,52,53,54,66,67,53,54,55,67,68,54,55,56,68,69,55,56,57,69,70,63,64,65,77,78,64,65,66,78,79,65,66,67,79,80,66,67,68,80,81,67,68,69,81,82,75,76,77,89,90,76,77,78,90,91,77,78,79,91,92,78,79,80,92,93,79,80,81,93,94,87,88,89,101,102,88,89,90,102,103,89,90,91,103,104,90,91,92,104,105,91,92,93,105,106,99,100,101,113,114,100,101,102,114,115,101,102,103,115,116,102,103,104,116,117,29,30,39,40,41,30,31,40,41,42,31,32,41,42,43,32,33,42,43,44,41,42,51,52,53,42,43,52,53,54,43,44,53,54,55,44,45,54,55,56,45,46,55,56,57,53,54,63,64,65,54,55,64,65,66,55,56,65,66,67,56,57,66,67,68,57,58,67,68,69,65,66,75,76,77,66,67,76,77,78,67,68,77,78,79,68,69,78,79,80,69,70,79,80,81,77,78,87,88,89,78,79,88,89,90,79,80,89,90,91,80,81,90,91,92,81,82,91,92,93,89,90,99,100,101,90,91,100,101,102,91,92,101,102,103,92,93,102,103,104,93,94,103,104,105,102,103,112,113,114,103,104,113,114,115,104,105,114,115,116,105,106,115,116,117,28,29,41,42,43,29,30,42,43,44,30,31,43,44,45,31,32,44,45,46,39,40,52,53,54,40,41,53,54,55,41,42,54,55,56,42,43,55,56,57,43,44,56,57,58,51,52,64,65,66,52,53,65,66,67,53,54,66,67,68,54,55,67,68,69,55,56,68,69,70,63,64,76,77,78,64,65,77,78,79,65,66,78,79,80,66,67,79,80,81,67,68,80,81,82,75,76,88,89,90,76,77,89,90,91,77,78,90,91,92,78,79,91,92,93,79,80,92,93,94,87,88,100,101,102,88,89,101,102,103,89,90,102,103,104,90,91,103,104,105,91,92,104,105,106,99,100,112,113,114,100,101,113,114,115,101,102,114,115,116,102,103,115,116,117,28,39,40,51,63,29,40,41,52,64,30,41,42,53,65,31,42,43,54,66,32,43,44,55,67,33,44,45,56,68,40,51,52,63,75,41,52,53,64,76,42,53,54,65,77,43,54,55,66,78,44,55,56,67,79,45,56,57,68,80,46,57,58,69,81,52,63,64,75,87,53,64,65,76,88,54,65,66,77,89,55,66,67,78,90,56,67,68,79,91,57,68,69,80,92,58,69,70,81,93,64,75,76,87,99,65,76,77,88,100,66,77,78,89,101,67,78,79,90,102,68,79,80,91,103,69,80,81,92,104,70,81,82,93,105,77,88,89,100,112,78,89,90,101,113,79,90,91,102,114,80,91,92,103,115,81,92,93,104,116,82,93,94,105,117,28,40,41,53,65,29,41,42,54,66,30,42,43,55,67,31,43,44,56,68,32,44,45,57,69,33,45,46,58,70,39,51,52,64,76,40,52,53,65,77,41,53,54,66,78,42,54,55,67,79,43,55,56,68,80,44,56,57,69,81,45,57,58,70,82,51,63,64,76,88,52,64,65,77,89,53,65,66,78,90,54,66,67,79,91,55,67,68,80,92,56,68,69,81,93,57,69,70,82,94,63,75,76,88,100,64,76,77,89,101,65,77,78,90,102,66,78,79,91,103,67,79,80,92,104,68,80,81,93,105,69,81,82,94,106,75,87,88,100,112,76,88,89,101,113,77,89,90,102,114,78,90,91,103,115,79,91,92,104,116,80,92,93,105,117,28,40,51,52,63,29,41,52,53,64,30,42,53,54,65,31,43,54,55,66,32,44,55,56,67,33,45,56,57,68,40,52,63,64,75,41,53,64,65,76,42,54,65,66,77,43,55,66,67,78,44,56,67,68,79,45,57,68,69,80,46,58,69,70,81,52,64,75,76,87,53,65,76,77,88,54,66,77,78,89,55,67,78,79,90,56,68,79,80,91,57,69,80,81,92,58,70,81,82,93,64,76,87,88,99,65,77,88,89,100,66,78,89,90,101,67,79,90,91,102,68,80,91,92,103,69,81,92,93,104,70,82,93,94,105,77,89,100,101,112,78,90,101,102,113,79,91,102,103,114,80,92,103,104,115,81,93,104,105,116,82,94,105,106,117,28,40,52,53,65
 
};
for(int ai=0;ai<1160; ai+=5)
{int aa1=ai,aa2=ai+1,aa3=ai+2,aa4=ai+3,aa5=ai+4;
int a1=a[aa1],a2=a[aa2],a3=a[aa3],a4=a[aa4],a5=a[aa5];
 
 
int b[]={
28,29,30,31,32,29,30,31,32,33,51,52,53,54,55,52,53,54,55,56,53,54,55,56,57,54,55,56,57,58,63,64,65,66,67,64,65,66,67,68,65,66,67,68,69,66,67,68,69,70,75,76,77,78,79,76,77,78,79,80,77,78,79,80,81,78,79,80,81,82,87,88,89,90,91,88,89,90,91,92,89,90,91,92,93,90,91,92,93,94,112,113,114,115,116,113,114,115,116,117,29,41,53,65,77,30,42,54,66,78,31,43,55,67,79,32,44,56,68,80,39,51,63,75,87,41,53,65,77,89,42,54,66,78,90,43,55,67,79,91,44,56,68,80,92,46,58,70,82,94,51,63,75,87,99,53,65,77,89,101,54,66,78,90,102,55,67,79,91,103,56,68,80,92,104,58,70,82,94,106,65,77,89,101,113,66,78,90,102,114,67,79,91,103,115,68,80,92,104,116
};
for(int bi=0;bi<200; bi+=5)
{int bb1=bi,bb2=bi+1,bb3=bi+2,bb4=bi+3,bb5=bi+4;
int b1=b[bb1],b2=b[bb2],b3=b[bb3],b4=b[bb4],b5=b[bb5];
 if(b1==a1||b1==a2||b1==a3||b1==a4||b1==a5||
    b2==a1||b2==a2||b2==a3||b2==a4||b2==a5||
    b3==a1||b3==a2||b3==a3||b3==a4||b3==a5||
    b4==a1||b4==a2||b4==a3||b4==a4||b4==a5||
    b5==a1||b5==a2||b5==a3||b5==a4||b5==a5
    ) continue;
 
int d[]={
28,29,30,40,42,29,30,31,41,43,30,31,32,42,44,31,32,33,43,45,39,40,41,51,53,40,41,42,52,54,41,42,43,53,55,42,43,44,54,56,43,44,45,55,57,44,45,46,56,58,51,52,53,63,65,52,53,54,64,66,53,54,55,65,67,54,55,56,66,68,55,56,57,67,69,56,57,58,68,70,63,64,65,75,77,64,65,66,76,78,65,66,67,77,79,66,67,68,78,80,67,68,69,79,81,68,69,70,80,82,75,76,77,87,89,76,77,78,88,90,77,78,79,89,91,78,79,80,90,92,79,80,81,91,93,80,81,82,92,94,87,88,89,99,101,88,89,90,100,102,89,90,91,101,103,90,91,92,102,104,91,92,93,103,105,92,93,94,104,106,28,29,40,52,53,29,30,41,53,54,30,31,42,54,55,31,32,43,55,56,32,33,44,56,57,39,40,51,63,64,40,41,52,64,65,41,42,53,65,66,42,43,54,66,67,43,44,55,67,68,44,45,56,68,69,51,52,63,75,76,52,53,64,76,77,53,54,65,77,78,54,55,66,78,79,55,56,67,79,80,56,57,68,80,81,63,64,75,87,88,64,65,76,88,89,65,66,77,89,90,66,67,78,90,91,67,68,79,91,92,68,69,80,92,93,75,76,87,99,100,76,77,88,100,101,77,78,89,101,102,78,79,90,102,103,79,80,91,103,104,80,81,92,104,105,88,89,100,112,113,89,90,101,113,114,90,91,102,114,115,91,92,103,115,116,92,93,104,116,117,28,29,41,52,53,29,30,42,53,54,30,31,43,54,55,31,32,44,55,56,32,33,45,56,57,40,41,53,64,65,41,42,54,65,66,42,43,55,66,67,43,44,56,67,68,44,45,57,68,69,45,46,58,69,70,52,53,65,76,77,53,54,66,77,78,54,55,67,78,79,55,56,68,79,80,56,57,69,80,81,57,58,70,81,82,64,65,77,88,89,65,66,78,89,90,66,67,79,90,91,67,68,80,91,92,68,69,81,92,93,69,70,82,93,94,76,77,89,100,101,77,78,90,101,102,78,79,91,102,103,79,80,92,103,104,80,81,93,104,105,81,82,94,105,106,88,89,101,112,113,89,90,102,113,114,90,91,103,114,115,91,92,104,115,116,92,93,105,116,117,39,41,51,52,53,40,42,52,53,54,41,43,53,54,55,42,44,54,55,56,43,45,55,56,57,44,46,56,57,58,51,53,63,64,65,52,54,64,65,66,53,55,65,66,67,54,56,66,67,68,55,57,67,68,69,56,58,68,69,70,63,65,75,76,77,64,66,76,77,78,65,67,77,78,79,66,68,78,79,80,67,69,79,80,81,68,70,80,81,82,75,77,87,88,89,76,78,88,89,90,77,79,89,90,91,78,80,90,91,92,79,81,91,92,93,80,82,92,93,94,87,89,99,100,101,88,90,100,101,102,89,91,101,102,103,90,92,102,103,104,91,93,103,104,105,92,94,104,105,106,100,102,112,113,114,101,103,113,114,115,102,104,114,115,116,103,105,115,116,117
};
for(int di=0;di<680; di+=5) 
{int dd1=di,dd2=di+1,dd3=di+2,dd4=di+3,dd5=di+4;
int d1=d[dd1],d2=d[dd2],d3=d[dd3],d4=d[dd4],d5=d[dd5];
if(
    d1==a1||d1==a2||d1==a3||d1==a4||d1==a5||
    d2==a1||d2==a2||d2==a3||d2==a4||d2==a5||
    d3==a1||d3==a2||d3==a3||d3==a4||d3==a5||
    d4==a1||d4==a2||d4==a3||d4==a4||d4==a5||
    d5==a1||d5==a2||d5==a3||d5==a4||d5==a5||
    d1==b1||d1==b2||d1==b3||d1==b4||d1==b5||
    d2==b1||d2==b2||d2==b3||d2==b4||d2==b5||
    d3==b1||d3==b2||d3==b3||d3==b4||d3==b5||
    d4==b1||d4==b2||d4==b3||d4==b4||d4==b5||
    d5==b1||d5==b2||d5==b3||d5==b4||d5==b5
    ) continue;
 
 
int e[]={
28,29,30,40,52,29,30,31,41,53,30,31,32,42,54,31,32,33,43,55,39,40,41,51,63,40,41,42,52,64,41,42,43,53,65,42,43,44,54,66,43,44,45,55,67,44,45,46,56,68,51,52,53,63,75,52,53,54,64,76,53,54,55,65,77,54,55,56,66,78,55,56,57,67,79,56,57,58,68,80,63,64,65,75,87,64,65,66,76,88,65,66,67,77,89,66,67,68,78,90,67,68,69,79,91,68,69,70,80,92,75,76,77,87,99,76,77,78,88,100,77,78,79,89,101,78,79,80,90,102,79,80,81,91,103,80,81,82,92,104,88,89,90,100,112,89,90,91,101,113,90,91,92,102,114,91,92,93,103,115,28,29,30,42,54,29,30,31,43,55,30,31,32,44,56,31,32,33,45,57,39,40,41,53,65,40,41,42,54,66,41,42,43,55,67,42,43,44,56,68,43,44,45,57,69,44,45,46,58,70,51,52,53,65,77,52,53,54,66,78,53,54,55,67,79,54,55,56,68,80,55,56,57,69,81,56,57,58,70,82,63,64,65,77,89,64,65,66,78,90,65,66,67,79,91,66,67,68,80,92,67,68,69,81,93,68,69,70,82,94,75,76,77,89,101,76,77,78,90,102,77,78,79,91,103,78,79,80,92,104,79,80,81,93,105,80,81,82,94,106,88,89,90,102,114,89,90,91,103,115,90,91,92,104,116,91,92,93,105,117,30,42,52,53,54,31,43,53,54,55,32,44,54,55,56,33,45,55,56,57,41,53,63,64,65,42,54,64,65,66,43,55,65,66,67,44,56,66,67,68,45,57,67,68,69,46,58,68,69,70,53,65,75,76,77,54,66,76,77,78,55,67,77,78,79,56,68,78,79,80,57,69,79,80,81,58,70,80,81,82,65,77,87,88,89,66,78,88,89,90,67,79,89,90,91,68,80,90,91,92,69,81,91,92,93,70,82,92,93,94,77,89,99,100,101,78,90,100,101,102,79,91,101,102,103,80,92,102,103,104,81,93,103,104,105,82,94,104,105,106,90,102,112,113,114,91,103,113,114,115,92,104,114,115,116,93,105,115,116,117,28,40,52,53,54,29,41,53,54,55,30,42,54,55,56,31,43,55,56,57,39,51,63,64,65,40,52,64,65,66,41,53,65,66,67,42,54,66,67,68,43,55,67,68,69,44,56,68,69,70,51,63,75,76,77,52,64,76,77,78,53,65,77,78,79,54,66,78,79,80,55,67,79,80,81,56,68,80,81,82,63,75,87,88,89,64,76,88,89,90,65,77,89,90,91,66,78,90,91,92,67,79,91,92,93,68,80,92,93,94,75,87,99,100,101,76,88,100,101,102,77,89,101,102,103,78,90,102,103,104,79,91,103,104,105,80,92,104,105,106,88,100,112,113,114,89,101,113,114,115,90,102,114,115,116,91,103,115,116,117
};
for(int ei=0;ei<400; ei+=5)
{int ee1=ei,ee2=ei+1,ee3=ei+2,ee4=ei+3,ee5=ei+4;
int e1=e[ee1],e2=e[ee2],e3=e[ee3],e4=e[ee4],e5=e[ee5];
 if(
    e1==a1||e1==a2||e1==a3||e1==a4||e1==a5||
    e2==a1||e2==a2||e2==a3||e2==a4||e2==a5||
    e3==a1||e3==a2||e3==a3||e3==a4||e3==a5||
    e4==a1||e4==a2||e4==a3||e4==a4||e4==a5||
    e5==a1||e5==a2||e5==a3||e5==a4||e5==a5||
    e1==b1||e1==b2||e1==b3||e1==b4||e1==b5||
    e2==b1||e2==b2||e2==b3||e2==b4||e2==b5||
    e3==b1||e3==b2||e3==b3||e3==b4||e3==b5||
    e4==b1||e4==b2||e4==b3||e4==b4||e4==b5||
    e5==b1||e5==b2||e5==b3||e5==b4||e5==b5||
    e1==d1||e1==d2||e1==d3||e1==d4||e1==d5||
    e2==d1||e2==d2||e2==d3||e2==d4||e2==d5||
    e3==d1||e3==d2||e3==d3||e3==d4||e3==d5||
    e4==d1||e4==d2||e4==d3||e4==d4||e4==d5||
    e5==d1||e5==d2||e5==d3||e5==d4||e5==d5
    ) continue;
 
int f[]={
28,29,41,42,54,29,30,42,43,55,30,31,43,44,56,32,33,45,46,58,39,40,52,53,65,40,41,53,54,66,41,42,54,55,67,42,43,55,56,68,43,44,56,57,69,51,52,64,65,77,52,53,65,66,78,53,54,66,67,79,54,55,67,68,80,55,56,68,69,81,56,57,69,70,82,63,64,76,77,89,64,65,77,78,90,65,66,78,79,91,66,67,79,80,92,67,68,80,81,93,68,69,81,82,94,76,77,89,90,102,77,78,90,91,103,78,79,91,92,104,79,80,92,93,105,80,81,93,94,106,89,90,102,103,115,90,91,103,104,116,91,92,104,105,117,28,29,39,40,51,30,31,41,42,53,31,32,42,43,54,32,33,43,44,55,41,42,52,53,64,42,43,53,54,65,43,44,54,55,66,44,45,55,56,67,45,46,56,57,68,52,53,63,64,75,53,54,64,65,76,54,55,65,66,77,55,56,66,67,78,56,57,67,68,79,57,58,68,69,80,64,65,75,76,87,65,66,76,77,88,66,67,77,78,89,67,68,78,79,90,68,69,79,80,91,69,70,80,81,92,76,77,87,88,99,77,78,88,89,100,78,79,89,90,101,79,80,90,91,102,80,81,91,92,103,89,90,100,101,112,90,91,101,102,113,91,92,102,103,114,31,42,43,53,54,32,43,44,54,55,33,44,45,55,56,42,53,54,64,65,43,54,55,65,66,44,55,56,66,67,45,56,57,67,68,46,57,58,68,69,53,64,65,75,76,54,65,66,76,77,55,66,67,77,78,56,67,68,78,79,57,68,69,79,80,58,69,70,80,81,65,76,77,87,88,66,77,78,88,89,67,78,79,89,90,68,79,80,90,91,69,80,81,91,92,70,81,82,92,93,77,88,89,99,100,78,89,90,100,101,79,90,91,101,102,80,91,92,102,103,81,92,93,103,104,90,101,102,112,113,91,102,103,113,114,92,103,104,114,115,94,105,106,116,117,28,40,41,53,54,29,41,42,54,55,30,42,43,55,56,39,51,52,64,65,40,52,53,65,66,41,53,54,66,67,42,54,55,67,68,43,55,56,68,69,51,63,64,76,77,52,64,65,77,78,53,65,66,78,79,54,66,67,79,80,55,67,68,80,81,56,68,69,81,82,63,75,76,88,89,64,76,77,89,90,65,77,78,90,91,66,78,79,91,92,67,79,80,92,93,68,80,81,93,94,76,88,89,101,102,77,89,90,102,103,78,90,91,103,104,79,91,92,104,105,80,92,93,105,106,87,99,100,112,113,89,101,102,114,115,90,102,103,115,116,91,103,104,116,117
};
for(int fi=0;fi<400; fi+=5)
{int ff1=fi,ff2=fi+1,ff3=fi+2,ff4=fi+3,ff5=fi+4;
int f1=f[ff1],f2=f[ff2],f3=f[ff3],f4=f[ff4],f5=f[ff5];
if(
    f1==a1||f1==a2||f1==a3||f1==a4||f1==a5||
    f2==a1||f2==a2||f2==a3||f2==a4||f2==a5||
    f3==a1||f3==a2||f3==a3||f3==a4||f3==a5||
    f4==a1||f4==a2||f4==a3||f4==a4||f4==a5||
    f5==a1||f5==a2||f5==a3||f5==a4||f5==a5||
    f1==b1||f1==b2||f1==b3||f1==b4||f1==b5||
    f2==b1||f2==b2||f2==b3||f2==b4||f2==b5||
    f3==b1||f3==b2||f3==b3||f3==b4||f3==b5||
    f4==b1||f4==b2||f4==b3||f4==b4||f4==b5||
    f5==b1||f5==b2||f5==b3||f5==b4||f5==b5||
    f1==d1||f1==d2||f1==d3||f1==d4||f1==d5||
    f2==d1||f2==d2||f2==d3||f2==d4||f2==d5||
    f3==d1||f3==d2||f3==d3||f3==d4||f3==d5||
    f4==d1||f4==d2||f4==d3||f4==d4||f4==d5||
    f5==d1||f5==d2||f5==d3||f5==d4||f5==d5||
    f1==e1||f1==e2||f1==e3||f1==e4||f1==e5||
    f2==e1||f2==e2||f2==e3||f2==e4||f2==e5||
    f3==e1||f3==e2||f3==e3||f3==e4||f3==e5||
    f4==e1||f4==e2||f4==e3||f4==e4||f4==e5||
    f5==e1||f5==e2||f5==e3||f5==e4||f5==e5
    ) continue;
 
 
int g[]={
29,30,41,52,53,30,31,42,53,54,31,32,43,54,55,32,33,44,55,56,40,41,52,63,64,41,42,53,64,65,42,43,54,65,66,43,44,55,66,67,44,45,56,67,68,45,46,57,68,69,52,53,64,75,76,53,54,65,76,77,54,55,66,77,78,55,56,67,78,79,56,57,68,79,80,57,58,69,80,81,64,65,76,87,88,65,66,77,88,89,66,67,78,89,90,67,68,79,90,91,68,69,80,91,92,69,70,81,92,93,76,77,88,99,100,77,78,89,100,101,78,79,90,101,102,79,80,91,102,103,80,81,92,103,104,81,82,93,104,105,89,90,101,112,113,90,91,102,113,114,91,92,103,114,115,92,93,104,115,116,28,29,41,53,54,29,30,42,54,55,30,31,43,55,56,31,32,44,56,57,39,40,52,64,65,40,41,53,65,66,41,42,54,66,67,42,43,55,67,68,43,44,56,68,69,44,45,57,69,70,51,52,64,76,77,52,53,65,77,78,53,54,66,78,79,54,55,67,79,80,55,56,68,80,81,56,57,69,81,82,63,64,76,88,89,64,65,77,89,90,65,66,78,90,91,66,67,79,91,92,67,68,80,92,93,68,69,81,93,94,75,76,88,100,101,76,77,89,101,102,77,78,90,102,103,78,79,91,103,104,79,80,92,104,105,80,81,93,105,106,88,89,101,113,114,89,90,102,114,115,90,91,103,115,116,91,92,104,116,117,30,40,41,42,52,31,41,42,43,53,32,42,43,44,54,33,43,44,45,55,41,51,52,53,63,42,52,53,54,64,43,53,54,55,65,44,54,55,56,66,45,55,56,57,67,46,56,57,58,68,53,63,64,65,75,54,64,65,66,76,55,65,66,67,77,56,66,67,68,78,57,67,68,69,79,58,68,69,70,80,65,75,76,77,87,66,76,77,78,88,67,77,78,79,89,68,78,79,80,90,69,79,80,81,91,70,80,81,82,92,77,87,88,89,99,78,88,89,90,100,79,89,90,91,101,80,90,91,92,102,81,91,92,93,103,82,92,93,94,104,90,100,101,102,112,91,101,102,103,113,92,102,103,104,114,93,103,104,105,115,28,40,41,42,54,29,41,42,43,55,30,42,43,44,56,31,43,44,45,57,39,51,52,53,65,40,52,53,54,66,41,53,54,55,67,42,54,55,56,68,43,55,56,57,69,44,56,57,58,70,51,63,64,65,77,52,64,65,66,78,53,65,66,67,79,54,66,67,68,80,55,67,68,69,81,56,68,69,70,82,63,75,76,77,89,64,76,77,78,90,65,77,78,79,91,66,78,79,80,92,67,79,80,81,93,68,80,81,82,94,75,87,88,89,101,76,88,89,90,102,77,89,90,91,103,78,90,91,92,104,79,91,92,93,105,80,92,93,94,106,88,100,101,102,114,89,101,102,103,115,90,102,103,104,116,91,103,104,105,117
};
for(int gi=0;gi<400; gi+=5)
{int gg1=gi,gg2=gi+1,gg3=gi+2,gg4=gi+3,gg5=gi+4;
int g1=g[gg1],g2=g[gg2],g3=g[gg3],g4=g[gg4],g5=g[gg5];
 if(
    g1==a1||g1==a2||g1==a3||g1==a4||g1==a5||
    g2==a1||g2==a2||g2==a3||g2==a4||g2==a5||
    g3==a1||g3==a2||g3==a3||g3==a4||g3==a5||
    g4==a1||g4==a2||g4==a3||g4==a4||g4==a5||
    g5==a1||g5==a2||g5==a3||g5==a4||g5==a5||
    g1==b1||g1==b2||g1==b3||g1==b4||g1==b5||
    g2==b1||g2==b2||g2==b3||g2==b4||g2==b5||
    g3==b1||g3==b2||g3==b3||g3==b4||g3==b5||
    g4==b1||g4==b2||g4==b3||g4==b4||g4==b5||
    g5==b1||g5==b2||g5==b3||g5==b4||g5==b5||
    g1==d1||g1==d2||g1==d3||g1==d4||g1==d5||
    g2==d1||g2==d2||g2==d3||g2==d4||g2==d5||
    g3==d1||g3==d2||g3==d3||g3==d4||g3==d5||
    g4==d1||g4==d2||g4==d3||g4==d4||g4==d5||
    g5==d1||g5==d2||g5==d3||g5==d4||g5==d5||
    g1==e1||g1==e2||g1==e3||g1==e4||g1==e5||
    g2==e1||g2==e2||g2==e3||g2==e4||g2==e5||
    g3==e1||g3==e2||g3==e3||g3==e4||g3==e5||
    g4==e1||g4==e2||g4==e3||g4==e4||g4==e5||
    g5==e1||g5==e2||g5==e3||g5==e4||g5==e5||
    g1==f1||g1==f2||g1==f3||g1==f4||g1==f5||
    g2==f1||g2==f2||g2==f3||g2==f4||g2==f5||
    g3==f1||g3==f2||g3==f3||g3==f4||g3==f5||
    g4==f1||g4==f2||g4==f3||g4==f4||g4==f5||
    g5==f1||g5==f2||g5==f3||g5==f4||g5==f5
    ) continue;
 
int h[]={
28,29,30,41,53,29,30,31,42,54,30,31,32,43,55,31,32,33,44,56,39,40,41,52,64,40,41,42,53,65,41,42,43,54,66,42,43,44,55,67,43,44,45,56,68,44,45,46,57,69,51,52,53,64,76,52,53,54,65,77,53,54,55,66,78,54,55,56,67,79,55,56,57,68,80,56,57,58,69,81,63,64,65,76,88,64,65,66,77,89,65,66,67,78,90,66,67,68,79,91,67,68,69,80,92,68,69,70,81,93,75,76,77,88,100,76,77,78,89,101,77,78,79,90,102,78,79,80,91,103,79,80,81,92,104,80,81,82,93,105,87,88,89,100,112,88,89,90,101,113,89,90,91,102,114,90,91,92,103,115,91,92,93,104,116,92,93,94,105,117,29,39,40,41,53,30,40,41,42,54,31,41,42,43,55,32,42,43,44,56,33,43,44,45,57,41,51,52,53,65,42,52,53,54,66,43,53,54,55,67,44,54,55,56,68,45,55,56,57,69,46,56,57,58,70,53,63,64,65,77,54,64,65,66,78,55,65,66,67,79,56,66,67,68,80,57,67,68,69,81,58,68,69,70,82,65,75,76,77,89,66,76,77,78,90,67,77,78,79,91,68,78,79,80,92,69,79,80,81,93,70,80,81,82,94,77,87,88,89,101,78,88,89,90,102,79,89,90,91,103,80,90,91,92,104,81,91,92,93,105,82,92,93,94,106,89,99,100,101,113,90,100,101,102,114,91,101,102,103,115,92,102,103,104,116,93,103,104,105,117,28,40,41,42,52,29,41,42,43,53,30,42,43,44,54,31,43,44,45,55,32,44,45,46,56,39,51,52,53,63,40,52,53,54,64,41,53,54,55,65,42,54,55,56,66,43,55,56,57,67,44,56,57,58,68,51,63,64,65,75,52,64,65,66,76,53,65,66,67,77,54,66,67,68,78,55,67,68,69,79,56,68,69,70,80,63,75,76,77,87,64,76,77,78,88,65,77,78,79,89,66,78,79,80,90,67,79,80,81,91,68,80,81,82,92,75,87,88,89,99,76,88,89,90,100,77,89,90,91,101,78,90,91,92,102,79,91,92,93,103,80,92,93,94,104,88,100,101,102,112,89,101,102,103,113,90,102,103,104,114,91,103,104,105,115,92,104,105,106,116,28,40,51,52,53,29,41,52,53,54,30,42,53,54,55,31,43,54,55,56,32,44,55,56,57,33,45,56,57,58,40,52,63,64,65,41,53,64,65,66,42,54,65,66,67,43,55,66,67,68,44,56,67,68,69,45,57,68,69,70,52,64,75,76,77,53,65,76,77,78,54,66,77,78,79,55,67,78,79,80,56,68,79,80,81,57,69,80,81,82,64,76,87,88,89,65,77,88,89,90,66,78,89,90,91,67,79,90,91,92,68,80,91,92,93,69,81,92,93,94,76,88,99,100,101,77,89,100,101,102,78,90,101,102,103,79,91,102,103,104,80,92,103,104,105,81,93,104,105,106,89,101,112,113,114,90,102,113,114,115,91,103,114,115,116,92,104,115,116,117
};
for(int hi=0;hi<400; hi+=5)
{int hh1=hi,hh2=hi+1,hh3=hi+2,hh4=hi+3,hh5=hi+4;
int h1=h[hh1],h2=h[hh2],h3=h[hh3],h4=h[hh4],h5=h[hh5];
    if(
    h1==a1||h1==a2||h1==a3||h1==a4||h1==a5||
    h2==a1||h2==a2||h2==a3||h2==a4||h2==a5||
    h3==a1||h3==a2||h3==a3||h3==a4||h3==a5||
    h4==a1||h4==a2||h4==a3||h4==a4||h4==a5||
    h5==a1||h5==a2||h5==a3||h5==a4||h5==a5||
    h1==b1||h1==b2||h1==b3||h1==b4||h1==b5||
    h2==b1||h2==b2||h2==b3||h2==b4||h2==b5||
    h3==b1||h3==b2||h3==b3||h3==b4||h3==b5||
    h4==b1||h4==b2||h4==b3||h4==b4||h4==b5||
    h5==b1||h5==b2||h5==b3||h5==b4||h5==b5||
    h1==d1||h1==d2||h1==d3||h1==d4||h1==d5||
    h2==d1||h2==d2||h2==d3||h2==d4||h2==d5||
    h3==d1||h3==d2||h3==d3||h3==d4||h3==d5||
    h4==d1||h4==d2||h4==d3||h4==d4||h4==d5||
    h5==d1||h5==d2||h5==d3||h5==d4||h5==d5||
    h1==e1||h1==e2||h1==e3||h1==e4||h1==e5||
    h2==e1||h2==e2||h2==e3||h2==e4||h2==e5||
    h3==e1||h3==e2||h3==e3||h3==e4||h3==e5||
    h4==e1||h4==e2||h4==e3||h4==e4||h4==e5||
    h5==e1||h5==e2||h5==e3||h5==e4||h5==e5||
    h1==f1||h1==f2||h1==f3||h1==f4||h1==f5||
    h2==f1||h2==f2||h2==f3||h2==f4||h2==f5||
    h3==f1||h3==f2||h3==f3||h3==f4||h3==f5||
    h4==f1||h4==f2||h4==f3||h4==f4||h4==f5||
    h5==f1||h5==f2||h5==f3||h5==f4||h5==f5||
    h1==g1||h1==g2||h1==g3||h1==g4||h1==g5||
    h2==g1||h2==g2||h2==g3||h2==g4||h2==g5||
    h3==g1||h3==g2||h3==g3||h3==g4||h3==g5||
    h4==g1||h4==g2||h4==g3||h4==g4||h4==g5||
    h5==g1||h5==g2||h5==g3||h5==g4||h5==g5
    ) continue;
 
 
int k[]={
28,29,30,40,41,29,30,31,41,42,30,31,32,42,43,31,32,33,43,44,39,40,41,51,52,40,41,42,52,53,41,42,43,53,54,42,43,44,54,55,43,44,45,55,56,44,45,46,56,57,51,52,53,63,64,52,53,54,64,65,53,54,55,65,66,54,55,56,66,67,55,56,57,67,68,56,57,58,68,69,63,64,65,75,76,64,65,66,76,77,65,66,67,77,78,66,67,68,78,79,67,68,69,79,80,68,69,70,80,81,75,76,77,87,88,76,77,78,88,89,77,78,79,89,90,78,79,80,90,91,79,80,81,91,92,80,81,82,92,93,87,88,89,99,100,88,89,90,100,101,89,90,91,101,102,90,91,92,102,103,91,92,93,103,104,92,93,94,104,105,100,101,102,112,113,101,102,103,113,114,102,103,104,114,115,103,104,105,115,116,104,105,106,116,117,28,29,30,41,42,29,30,31,42,43,30,31,32,43,44,31,32,33,44,45,39,40,41,52,53,40,41,42,53,54,41,42,43,54,55,42,43,44,55,56,43,44,45,56,57,44,45,46,57,58,51,52,53,64,65,52,53,54,65,66,53,54,55,66,67,54,55,56,67,68,55,56,57,68,69,56,57,58,69,70,63,64,65,76,77,64,65,66,77,78,65,66,67,78,79,66,67,68,79,80,67,68,69,80,81,68,69,70,81,82,75,76,77,88,89,76,77,78,89,90,77,78,79,90,91,78,79,80,91,92,79,80,81,92,93,80,81,82,93,94,87,88,89,100,101,88,89,90,101,102,89,90,91,102,103,90,91,92,103,104,91,92,93,104,105,92,93,94,105,106,99,100,101,112,113,100,101,102,113,114,101,102,103,114,115,102,103,104,115,116,103,104,105,116,117,28,29,39,40,41,29,30,40,41,42,30,31,41,42,43,31,32,42,43,44,32,33,43,44,45,40,41,51,52,53,41,42,52,53,54,42,43,53,54,55,43,44,54,55,56,44,45,55,56,57,45,46,56,57,58,52,53,63,64,65,53,54,64,65,66,54,55,65,66,67,55,56,66,67,68,56,57,67,68,69,57,58,68,69,70,64,65,75,76,77,65,66,76,77,78,66,67,77,78,79,67,68,78,79,80,68,69,79,80,81,69,70,80,81,82,76,77,87,88,89,77,78,88,89,90,78,79,89,90,91,79,80,90,91,92,80,81,91,92,93,81,82,92,93,94,88,89,99,100,101,89,90,100,101,102,90,91,101,102,103,91,92,102,103,104,92,93,103,104,105,93,94,104,105,106,101,102,112,113,114,102,103,113,114,115,103,104,114,115,116,104,105,115,116,117,28,29,40,41,42,29,30,41,42,43,30,31,42,43,44,31,32,43,44,45,32,33,44,45,46,39,40,51,52,53,40,41,52,53,54,41,42,53,54,55,42,43,54,55,56,43,44,55,56,57,44,45,56,57,58,51,52,63,64,65,52,53,64,65,66,53,54,65,66,67,54,55,66,67,68,55,56,67,68,69,56,57,68,69,70,63,64,75,76,77,64,65,76,77,78,65,66,77,78,79,66,67,78,79,80,67,68,79,80,81,68,69,80,81,82,75,76,87,88,89,76,77,88,89,90,77,78,89,90,91,78,79,90,91,92,79,80,91,92,93,80,81,92,93,94,87,88,99,100,101,88,89,100,101,102,89,90,101,102,103,90,91,102,103,104,91,92,103,104,105,92,93,104,105,106,100,101,112,113,114,101,102,113,114,115,102,103,114,115,116,103,104,115,116,117,28,29,40,41,52,29,30,41,42,53,30,31,42,43,54,31,32,43,44,55,32,33,44,45,56,39,40,51,52,63,40,41,52,53,64,41,42,53,54,65,42,43,54,55,66,43,44,55,56,67,44,45,56,57,68,45,46,57,58,69,51,52,63,64,75,52,53,64,65,76,53,54,65,66,77,54,55,66,67,78,55,56,67,68,79,56,57,68,69,80,57,58,69,70,81,63,64,75,76,87,64,65,76,77,88,65,66,77,78,89,66,67,78,79,90,67,68,79,80,91,68,69,80,81,92,69,70,81,82,93,75,76,87,88,99,76,77,88,89,100,77,78,89,90,101,78,79,90,91,102,79,80,91,92,103,80,81,92,93,104,81,82,93,94,105,88,89,100,101,112,89,90,101,102,113,90,91,102,103,114,91,92,103,104,115,92,93,104,105,116,93,94,105,106,117,28,29,40,41,53,29,30,41,42,54,30,31,42,43,55,31,32,43,44,56,32,33,44,45,57,39,40,51,52,64,40,41,52,53,65,41,42,53,54,66,42,43,54,55,67,43,44,55,56,68,44,45,56,57,69,45,46,57,58,70,51,52,63,64,76,52,53,64,65,77,53,54,65,66,78,54,55,66,67,79,55,56,67,68,80,56,57,68,69,81,57,58,69,70,82,63,64,75,76,88,64,65,76,77,89,65,66,77,78,90,66,67,78,79,91,67,68,79,80,92,68,69,80,81,93,69,70,81,82,94,75,76,87,88,100,76,77,88,89,101,77,78,89,90,102,78,79,90,91,103,79,80,91,92,104,80,81,92,93,105,81,82,93,94,106,87,88,99,100,112,88,89,100,101,113,89,90,101,102,114,90,91,102,103,115,91,92,103,104,116,92,93,104,105,117,28,39,40,51,52,29,40,41,52,53,30,41,42,53,54,31,42,43,54,55,32,43,44,55,56,33,44,45,56,57,40,51,52,63,64,41,52,53,64,65,42,53,54,65,66,43,54,55,66,67,44,55,56,67,68,45,56,57,68,69,46,57,58,69,70,52,63,64,75,76,53,64,65,76,77,54,65,66,77,78,55,66,67,78,79,56,67,68,79,80,57,68,69,80,81,58,69,70,81,82,64,75,76,87,88,65,76,77,88,89,66,77,78,89,90,67,78,79,90,91,68,79,80,91,92,69,80,81,92,93,70,81,82,93,94,76,87,88,99,100,77,88,89,100,101,78,89,90,101,102,79,90,91,102,103,80,91,92,103,104,81,92,93,104,105,82,93,94,105,106,89,100,101,112,113,90,101,102,113,114,91,102,103,114,115,92,103,104,115,116,93,104,105,116,117,28,40,41,52,53,29,41,42,53,54,30,42,43,54,55,31,43,44,55,56,32,44,45,56,57,33,45,46,57,58,39,51,52,63,64,40,52,53,64,65,41,53,54,65,66,42,54,55,66,67,43,55,56,67,68,44,56,57,68,69,45,57,58,69,70,51,63,64,75,76,52,64,65,76,77,53,65,66,77,78,54,66,67,78,79,55,67,68,79,80,56,68,69,80,81,57,69,70,81,82,63,75,76,87,88,64,76,77,88,89,65,77,78,89,90,66,78,79,90,91,67,79,80,91,92,68,80,81,92,93,69,81,82,93,94,75,87,88,99,100,76,88,89,100,101,77,89,90,101,102,78,90,91,102,103,79,91,92,103,104,80,92,93,104,105,81,93,94,105,106,88,100,101,112,113,89,101,102,113,114,90,102,103,114,115,91,103,104,115,116,92,104,105,116,117
};
for(int ki=0;ki<400; ki+=5) 
{int kk1=ki,kk2=ki+1,kk3=ki+2,kk4=ki+3,kk5=ki+4;
int k1=k[kk1],k2=k[kk2],k3=k[kk3],k4=k[kk4],k5=k[kk5];
     if(
    k1==a1||k1==a2||k1==a3||k1==a4||k1==a5||
    k2==a1||k2==a2||k2==a3||k2==a4||k2==a5||
    k3==a1||k3==a2||k3==a3||k3==a4||k3==a5||
    k4==a1||k4==a2||k4==a3||k4==a4||k4==a5||
    k5==a1||k5==a2||k5==a3||k5==a4||k5==a5||
    k1==b1||k1==b2||k1==b3||k1==b4||k1==b5||
    k2==b1||k2==b2||k2==b3||k2==b4||k2==b5||
    k3==b1||k3==b2||k3==b3||k3==b4||k3==b5||
    k4==b1||k4==b2||k4==b3||k4==b4||k4==b5||
    k5==b1||k5==b2||k5==b3||k5==b4||k5==b5||
    k1==d1||k1==d2||k1==d3||k1==d4||k1==d5||
    k2==d1||k2==d2||k2==d3||k2==d4||k2==d5||
    k3==d1||k3==d2||k3==d3||k3==d4||k3==d5||
    k4==d1||k4==d2||k4==d3||k4==d4||k4==d5||
    k5==d1||k5==d2||k5==d3||k5==d4||k5==d5||
    k1==e1||k1==e2||k1==e3||k1==e4||k1==e5||
    k2==e1||k2==e2||k2==e3||k2==e4||k2==e5||
    k3==e1||k3==e2||k3==e3||k3==e4||k3==e5||
    k4==e1||k4==e2||k4==e3||k4==e4||k4==e5||
    k5==e1||k5==e2||k5==e3||k5==e4||k5==e5||
    k1==f1||k1==f2||k1==f3||k1==f4||k1==f5||
    k2==f1||k2==f2||k2==f3||k2==f4||k2==f5||
    k3==f1||k3==f2||k3==f3||k3==f4||k3==f5||
    k4==f1||k4==f2||k4==f3||k4==f4||k4==f5||
    k5==f1||k5==f2||k5==f3||k5==f4||k5==f5||
    k1==g1||k1==g2||k1==g3||k1==g4||k1==g5||
    k2==g1||k2==g2||k2==g3||k2==g4||k2==g5||
    k3==g1||k3==g2||k3==g3||k3==g4||k3==g5||
    k4==g1||k4==g2||k4==g3||k4==g4||k4==g5||
    k5==g1||k5==g2||k5==g3||k5==g4||k5==g5||
    k1==h1||k1==h2||k1==h3||k1==h4||k1==h5||
    k2==h1||k2==h2||k2==h3||k2==h4||k2==h5||
    k3==h1||k3==h2||k3==h3||k3==h4||k3==h5||
    k4==h1||k4==h2||k4==h3||k4==h4||k4==h5||
    k5==h1||k5==h2||k5==h3||k5==h4||k5==h5
    ) continue;
 
int m[]={
28,29,39,40,52,29,30,40,41,53,30,31,41,42,54,31,32,42,43,55,32,33,43,44,56,40,41,51,52,64,41,42,52,53,65,42,43,53,54,66,43,44,54,55,67,44,45,55,56,68,45,46,56,57,69,52,53,63,64,76,53,54,64,65,77,54,55,65,66,78,55,56,66,67,79,56,57,67,68,80,57,58,68,69,81,64,65,75,76,88,65,66,76,77,89,66,67,77,78,90,67,68,78,79,91,68,69,79,80,92,69,70,80,81,93,76,77,87,88,100,77,78,88,89,101,78,79,89,90,102,79,80,90,91,103,80,81,91,92,104,81,82,92,93,105,88,89,99,100,112,89,90,100,101,113,90,91,101,102,114,91,92,102,103,115,92,93,103,104,116,93,94,104,105,117,28,29,41,42,53,29,30,42,43,54,30,31,43,44,55,31,32,44,45,56,32,33,45,46,57,39,40,52,53,64,40,41,53,54,65,41,42,54,55,66,42,43,55,56,67,43,44,56,57,68,44,45,57,58,69,51,52,64,65,76,52,53,65,66,77,53,54,66,67,78,54,55,67,68,79,55,56,68,69,80,56,57,69,70,81,63,64,76,77,88,64,65,77,78,89,65,66,78,79,90,66,67,79,80,91,67,68,80,81,92,68,69,81,82,93,75,76,88,89,100,76,77,89,90,101,77,78,90,91,102,78,79,91,92,103,79,80,92,93,104,80,81,93,94,105,87,88,100,101,112,88,89,101,102,113,89,90,102,103,114,90,91,103,104,115,91,92,104,105,116,92,93,105,106,117,29,39,40,41,52,30,40,41,42,53,31,41,42,43,54,32,42,43,44,55,33,43,44,45,56,41,51,52,53,64,42,52,53,54,65,43,53,54,55,66,44,54,55,56,67,45,55,56,57,68,46,56,57,58,69,53,63,64,65,76,54,64,65,66,77,55,65,66,67,78,56,66,67,68,79,57,67,68,69,80,58,68,69,70,81,65,75,76,77,88,66,76,77,78,89,67,77,78,79,90,68,78,79,80,91,69,79,80,81,92,70,80,81,82,93,77,87,88,89,100,78,88,89,90,101,79,89,90,91,102,80,90,91,92,103,81,91,92,93,104,82,92,93,94,105,89,99,100,101,112,90,100,101,102,113,91,101,102,103,114,92,102,103,104,115,93,103,104,105,116,94,104,105,106,117,28,39,40,41,51,29,40,41,42,52,30,41,42,43,53,31,42,43,44,54,32,43,44,45,55,33,44,45,46,56,40,51,52,53,63,41,52,53,54,64,42,53,54,55,65,43,54,55,56,66,44,55,56,57,67,45,56,57,58,68,52,63,64,65,75,53,64,65,66,76,54,65,66,67,77,55,66,67,68,78,56,67,68,69,79,57,68,69,70,80,64,75,76,77,87,65,76,77,78,88,66,77,78,79,89,67,78,79,80,90,68,79,80,81,91,69,80,81,82,92,76,87,88,89,99,77,88,89,90,100,78,89,90,91,101,79,90,91,92,102,80,91,92,93,103,81,92,93,94,104,89,100,101,102,112,90,101,102,103,113,91,102,103,104,114,92,103,104,105,115,93,104,105,106,116,28,39,40,41,53,29,40,41,42,54,30,41,42,43,55,31,42,43,44,56,32,43,44,45,57,33,44,45,46,58,40,51,52,53,65,41,52,53,54,66,42,53,54,55,67,43,54,55,56,68,44,55,56,57,69,45,56,57,58,70,52,63,64,65,77,53,64,65,66,78,54,65,66,67,79,55,66,67,68,80,56,67,68,69,81,57,68,69,70,82,64,75,76,77,89,65,76,77,78,90,66,77,78,79,91,67,78,79,80,92,68,79,80,81,93,69,80,81,82,94,76,87,88,89,101,77,88,89,90,102,78,89,90,91,103,79,90,91,92,104,80,91,92,93,105,81,92,93,94,106,88,99,100,101,113,89,100,101,102,114,90,101,102,103,115,91,102,103,104,116,92,103,104,105,117,28,39,40,52,53,29,40,41,53,54,30,41,42,54,55,31,42,43,55,56,32,43,44,56,57,33,44,45,57,58,40,51,52,64,65,41,52,53,65,66,42,53,54,66,67,43,54,55,67,68,44,55,56,68,69,45,56,57,69,70,52,63,64,76,77,53,64,65,77,78,54,65,66,78,79,55,66,67,79,80,56,67,68,80,81,57,68,69,81,82,64,75,76,88,89,65,76,77,89,90,66,77,78,90,91,67,78,79,91,92,68,79,80,92,93,69,80,81,93,94,76,87,88,100,101,77,88,89,101,102,78,89,90,102,103,79,90,91,103,104,80,91,92,104,105,81,92,93,105,106,88,99,100,112,113,89,100,101,113,114,90,101,102,114,115,91,102,103,115,116,92,103,104,116,117,28,40,41,42,53,29,41,42,43,54,30,42,43,44,55,31,43,44,45,56,32,44,45,46,57,39,51,52,53,64,40,52,53,54,65,41,53,54,55,66,42,54,55,56,67,43,55,56,57,68,44,56,57,58,69,51,63,64,65,76,52,64,65,66,77,53,65,66,67,78,54,66,67,68,79,55,67,68,69,80,56,68,69,70,81,63,75,76,77,88,64,76,77,78,89,65,77,78,79,90,66,78,79,80,91,67,79,80,81,92,68,80,81,82,93,75,87,88,89,100,76,88,89,90,101,77,89,90,91,102,78,90,91,92,103,79,91,92,93,104,80,92,93,94,105,87,99,100,101,112,88,100,101,102,113,89,101,102,103,114,90,102,103,104,115,91,103,104,105,116,92,104,105,106,117,28,40,41,51,52,29,41,42,52,53,30,42,43,53,54,31,43,44,54,55,32,44,45,55,56,33,45,46,56,57,40,52,53,63,64,41,53,54,64,65,42,54,55,65,66,43,55,56,66,67,44,56,57,67,68,45,57,58,68,69,52,64,65,75,76,53,65,66,76,77,54,66,67,77,78,55,67,68,78,79,56,68,69,79,80,57,69,70,80,81,64,76,77,87,88,65,77,78,88,89,66,78,79,89,90,67,79,80,90,91,68,80,81,91,92,69,81,82,92,93,76,88,89,99,100,77,89,90,100,101,78,90,91,101,102,79,91,92,102,103,80,92,93,103,104,81,93,94,104,105,89,101,102,112,113,90,102,103,113,114,91,103,104,114,115,92,104,105,115,116,93,105,106,116,117
};
for(int mi=0;mi<400; mi+=5)
{int mm1=mi,mm2=mi+1,mm3=mi+2,mm4=mi+3,mm5=mi+4;
int m1=m[mm1],m2=m[mm2],m3=m[mm3],m4=m[mm4],m5=m[mm5];
 if(
    m1==a1||m1==a2||m1==a3||m1==a4||m1==a5||
    m2==a1||m2==a2||m2==a3||m2==a4||m2==a5||
    m3==a1||m3==a2||m3==a3||m3==a4||m3==a5||
    m4==a1||m4==a2||m4==a3||m4==a4||m4==a5||
    m5==a1||m5==a2||m5==a3||m5==a4||m5==a5||
    m1==b1||m1==b2||m1==b3||m1==b4||m1==b5||
    m2==b1||m2==b2||m2==b3||m2==b4||m2==b5||
    m3==b1||m3==b2||m3==b3||m3==b4||m3==b5||
    m4==b1||m4==b2||m4==b3||m4==b4||m4==b5||
    m5==b1||m5==b2||m5==b3||m5==b4||m5==b5||
    m1==d1||m1==d2||m1==d3||m1==d4||m1==d5||
    m2==d1||m2==d2||m2==d3||m2==d4||m2==d5||
    m3==d1||m3==d2||m3==d3||m3==d4||m3==d5||
    m4==d1||m4==d2||m4==d3||m4==d4||m4==d5||
    m5==d1||m5==d2||m5==d3||m5==d4||m5==d5||
    m1==e1||m1==e2||m1==e3||m1==e4||m1==e5||
    m2==e1||m2==e2||m2==e3||m2==e4||m2==e5||
    m3==e1||m3==e2||m3==e3||m3==e4||m3==e5||
    m4==e1||m4==e2||m4==e3||m4==e4||m4==e5||
    m5==e1||m5==e2||m5==e3||m5==e4||m5==e5||
    m1==f1||m1==f2||m1==f3||m1==f4||m1==f5||
    m2==f1||m2==f2||m2==f3||m2==f4||m2==f5||
    m3==f1||m3==f2||m3==f3||m3==f4||m3==f5||
    m4==f1||m4==f2||m4==f3||m4==f4||m4==f5||
    m5==f1||m5==f2||m5==f3||m5==f4||m5==f5||
    m1==g1||m1==g2||m1==g3||m1==g4||m1==g5||
    m2==g1||m2==g2||m2==g3||m2==g4||m2==g5||
    m3==g1||m3==g2||m3==g3||m3==g4||m3==g5||
    m4==g1||m4==g2||m4==g3||m4==g4||m4==g5||
    m5==g1||m5==g2||m5==g3||m5==g4||m5==g5||
    m1==h1||m1==h2||m1==h3||m1==h4||m1==h5||
    m2==h1||m2==h2||m2==h3||m2==h4||m2==h5||
    m3==h1||m3==h2||m3==h3||m3==h4||m3==h5||
    m4==h1||m4==h2||m4==h3||m4==h4||m4==h5||
    m5==h1||m5==h2||m5==h3||m5==h4||m5==h5||
    m1==k1||m1==k2||m1==k3||m1==k4||m1==k5||
    m2==k1||m2==k2||m2==k3||m2==k4||m2==k5||
    m3==k1||m3==k2||m3==k3||m3==k4||m3==k5||
    m4==k1||m4==k2||m4==k3||m4==k4||m4==k5||
    m5==k1||m5==k2||m5==k3||m5==k4||m5==k5
    ) continue; 
 
int n[]={
28,29,30,31,40,29,30,31,32,41,30,31,32,33,42,39,40,41,42,51,40,41,42,43,52,41,42,43,44,53,42,43,44,45,54,43,44,45,46,55,51,52,53,54,63,52,53,54,55,64,53,54,55,56,65,54,55,56,57,66,55,56,57,58,67,63,64,65,66,75,64,65,66,67,76,65,66,67,68,77,66,67,68,69,78,67,68,69,70,79,75,76,77,78,87,76,77,78,79,88,77,78,79,80,89,78,79,80,81,90,79,80,81,82,91,87,88,89,90,99,88,89,90,91,100,89,90,91,92,101,90,91,92,93,102,91,92,93,94,103,100,101,102,103,112,101,102,103,104,113,102,103,104,105,114,103,104,105,106,115,28,29,30,31,43,29,30,31,32,44,30,31,32,33,45,39,40,41,42,54,40,41,42,43,55,41,42,43,44,56,42,43,44,45,57,43,44,45,46,58,51,52,53,54,66,52,53,54,55,67,53,54,55,56,68,54,55,56,57,69,55,56,57,58,70,63,64,65,66,78,64,65,66,67,79,65,66,67,68,80,66,67,68,69,81,67,68,69,70,82,75,76,77,78,90,76,77,78,79,91,77,78,79,80,92,78,79,80,81,93,79,80,81,82,94,87,88,89,90,102,88,89,90,91,103,89,90,91,92,104,90,91,92,93,105,91,92,93,94,106,99,100,101,102,114,100,101,102,103,115,101,102,103,104,116,102,103,104,105,117,30,39,40,41,42,31,40,41,42,43,32,41,42,43,44,33,42,43,44,45,42,51,52,53,54,43,52,53,54,55,44,53,54,55,56,45,54,55,56,57,46,55,56,57,58,54,63,64,65,66,55,64,65,66,67,56,65,66,67,68,57,66,67,68,69,58,67,68,69,70,66,75,76,77,78,67,76,77,78,79,68,77,78,79,80,69,78,79,80,81,70,79,80,81,82,78,87,88,89,90,79,88,89,90,91,80,89,90,91,92,81,90,91,92,93,82,91,92,93,94,90,99,100,101,102,91,100,101,102,103,92,101,102,103,104,93,102,103,104,105,94,103,104,105,106,103,112,113,114,115,104,113,114,115,116,105,114,115,116,117,28,40,41,42,43,29,41,42,43,44,30,42,43,44,45,31,43,44,45,46,39,51,52,53,54,40,52,53,54,55,41,53,54,55,56,42,54,55,56,57,43,55,56,57,58,51,63,64,65,66,52,64,65,66,67,53,65,66,67,68,54,66,67,68,69,55,67,68,69,70,63,75,76,77,78,64,76,77,78,79,65,77,78,79,80,66,78,79,80,81,67,79,80,81,82,75,87,88,89,90,76,88,89,90,91,77,89,90,91,92,78,90,91,92,93,79,91,92,93,94,87,99,100,101,102,88,100,101,102,103,89,101,102,103,104,90,102,103,104,105,91,103,104,105,106,100,112,113,114,115,101,113,114,115,116,102,114,115,116,117,28,29,40,52,64,29,30,41,53,65,30,31,42,54,66,31,32,43,55,67,32,33,44,56,68,39,40,51,63,75,40,41,52,64,76,41,42,53,65,77,42,43,54,66,78,43,44,55,67,79,44,45,56,68,80,45,46,57,69,81,51,52,63,75,87,52,53,64,76,88,53,54,65,77,89,54,55,66,78,90,55,56,67,79,91,56,57,68,80,92,57,58,69,81,93,63,64,75,87,99,64,65,76,88,100,65,66,77,89,101,66,67,78,90,102,67,68,79,91,103,68,69,80,92,104,69,70,81,93,105,76,77,88,100,112,77,78,89,101,113,78,79,90,102,114,79,80,91,103,115,80,81,92,104,116,81,82,93,105,117,28,29,41,53,65,29,30,42,54,66,30,31,43,55,67,31,32,44,56,68,32,33,45,57,69,39,40,52,64,76,40,41,53,65,77,41,42,54,66,78,42,43,55,67,79,43,44,56,68,80,44,45,57,69,81,45,46,58,70,82,51,52,64,76,88,52,53,65,77,89,53,54,66,78,90,54,55,67,79,91,55,56,68,80,92,56,57,69,81,93,57,58,70,82,94,63,64,76,88,100,64,65,77,89,101,65,66,78,90,102,66,67,79,91,103,67,68,80,92,104,68,69,81,93,105,69,70,82,94,106,75,76,88,100,112,76,77,89,101,113,77,78,90,102,114,78,79,91,103,115,79,80,92,104,116,80,81,93,105,117,28,40,52,63,64,29,41,53,64,65,30,42,54,65,66,31,43,55,66,67,32,44,56,67,68,33,45,57,68,69,40,52,64,75,76,41,53,65,76,77,42,54,66,77,78,43,55,67,78,79,44,56,68,79,80,45,57,69,80,81,46,58,70,81,82,52,64,76,87,88,53,65,77,88,89,54,66,78,89,90,55,67,79,90,91,56,68,80,91,92,57,69,81,92,93,58,70,82,93,94,64,76,88,99,100,65,77,89,100,101,66,78,90,101,102,67,79,91,102,103,68,80,92,103,104,69,81,93,104,105,70,82,94,105,106,77,89,101,112,113,78,90,102,113,114,79,91,103,114,115,80,92,104,115,116,81,93,105,116,117,28,40,52,64,65,29,41,53,65,66,30,42,54,66,67,31,43,55,67,68,32,44,56,68,69,33,45,57,69,70,39,51,63,75,76,40,52,64,76,77,41,53,65,77,78,42,54,66,78,79,43,55,67,79,80,44,56,68,80,81,45,57,69,81,82,51,63,75,87,88,52,64,76,88,89,53,65,77,89,90,54,66,78,90,91,55,67,79,91,92,56,68,80,92,93,57,69,81,93,94,63,75,87,99,100,64,76,88,100,101,65,77,89,101,102,66,78,90,102,103,67,79,91,103,104,68,80,92,104,105,69,81,93,105,106,76,88,100,112,113,77,89,101,113,114,78,90,102,114,115,79,91,103,115,116,80,92,104,116,117
};
for(int ni=0;ni<400; ni+=5)
{int nn1=ni,nn2=ni+1,nn3=ni+2,nn4=ni+3,nn5=ni+4;
int n1=n[nn1],n2=n[nn2],n3=n[nn3],n4=n[nn4],n5=n[nn5];
  if(
    n1==a1||n1==a2||n1==a3||n1==a4||n1==a5||
    n2==a1||n2==a2||n2==a3||n2==a4||n2==a5||
    n3==a1||n3==a2||n3==a3||n3==a4||n3==a5||
    n4==a1||n4==a2||n4==a3||n4==a4||n4==a5||
    n5==a1||n5==a2||n5==a3||n5==a4||n5==a5||
    n1==b1||n1==b2||n1==b3||n1==b4||n1==b5||
    n2==b1||n2==b2||n2==b3||n2==b4||n2==b5||
    n3==b1||n3==b2||n3==b3||n3==b4||n3==b5||
    n4==b1||n4==b2||n4==b3||n4==b4||n4==b5||
    n5==b1||n5==b2||n5==b3||n5==b4||n5==b5||
    n1==d1||n1==d2||n1==d3||n1==d4||n1==d5||
    n2==d1||n2==d2||n2==d3||n2==d4||n2==d5||
    n3==d1||n3==d2||n3==d3||n3==d4||n3==d5||
    n4==d1||n4==d2||n4==d3||n4==d4||n4==d5||
    n5==d1||n5==d2||n5==d3||n5==d4||n5==d5||
    n1==e1||n1==e2||n1==e3||n1==e4||n1==e5||
    n2==e1||n2==e2||n2==e3||n2==e4||n2==e5||
    n3==e1||n3==e2||n3==e3||n3==e4||n3==e5||
    n4==e1||n4==e2||n4==e3||n4==e4||n4==e5||
    n5==e1||n5==e2||n5==e3||n5==e4||n5==e5||
    n1==f1||n1==f2||n1==f3||n1==f4||n1==f5||
    n2==f1||n2==f2||n2==f3||n2==f4||n2==f5||
    n3==f1||n3==f2||n3==f3||n3==f4||n3==f5||
    n4==f1||n4==f2||n4==f3||n4==f4||n4==f5||
    n5==f1||n5==f2||n5==f3||n5==f4||n5==f5||
    n1==g1||n1==g2||n1==g3||n1==g4||n1==g5||
    n2==g1||n2==g2||n2==g3||n2==g4||n2==g5||
    n3==g1||n3==g2||n3==g3||n3==g4||n3==g5||
    n4==g1||n4==g2||n4==g3||n4==g4||n4==g5||
    n5==g1||n5==g2||n5==g3||n5==g4||n5==g5||
    n1==h1||n1==h2||n1==h3||n1==h4||n1==h5||
    n2==h1||n2==h2||n2==h3||n2==h4||n2==h5||
    n3==h1||n3==h2||n3==h3||n3==h4||n3==h5||
    n4==h1||n4==h2||n4==h3||n4==h4||n4==h5||
    n5==h1||n5==h2||n5==h3||n5==h4||n5==h5||
    n1==k1||n1==k2||n1==k3||n1==k4||n1==k5||
    n2==k1||n2==k2||n2==k3||n2==k4||n2==k5||
    n3==k1||n3==k2||n3==k3||n3==k4||n3==k5||
    n4==k1||n4==k2||n4==k3||n4==k4||n4==k5||
    n5==k1||n5==k2||n5==k3||n5==k4||n5==k5||
    n1==m1||n1==m2||n1==m3||n1==m4||n1==m5||
    n2==m1||n2==m2||n2==m3||n2==m4||n2==m5||
    n3==m1||n3==m2||n3==m3||n3==m4||n3==m5||
    n4==m1||n4==m2||n4==m3||n4==m4||n4==m5||
    n5==m1||n5==m2||n5==m3||n5==m4||n5==m5
    ) continue;
 
{int p[]={
28,29,30,31,41,29,30,31,32,42,30,31,32,33,43,39,40,41,42,52,40,41,42,43,53,41,42,43,44,54,42,43,44,45,55,43,44,45,46,56,51,52,53,54,64,52,53,54,55,65,53,54,55,56,66,54,55,56,57,67,55,56,57,58,68,63,64,65,66,76,64,65,66,67,77,65,66,67,68,78,66,67,68,69,79,67,68,69,70,80,75,76,77,78,88,76,77,78,79,89,77,78,79,80,90,78,79,80,81,91,79,80,81,82,92,87,88,89,90,100,88,89,90,91,101,89,90,91,92,102,90,91,92,93,103,91,92,93,94,104,99,100,101,102,112,100,101,102,103,113,101,102,103,104,114,102,103,104,105,115,103,104,105,106,116,28,29,30,31,42,29,30,31,32,43,30,31,32,33,44,39,40,41,42,53,40,41,42,43,54,41,42,43,44,55,42,43,44,45,56,43,44,45,46,57,51,52,53,54,65,52,53,54,55,66,53,54,55,56,67,54,55,56,57,68,55,56,57,58,69,63,64,65,66,77,64,65,66,67,78,65,66,67,68,79,66,67,68,69,80,67,68,69,70,81,75,76,77,78,89,76,77,78,79,90,77,78,79,80,91,78,79,80,81,92,79,80,81,82,93,87,88,89,90,101,88,89,90,91,102,89,90,91,92,103,90,91,92,93,104,91,92,93,94,105,99,100,101,102,113,100,101,102,103,114,101,102,103,104,115,102,103,104,105,116,103,104,105,106,117,29,39,40,41,42,30,40,41,42,43,31,41,42,43,44,32,42,43,44,45,33,43,44,45,46,41,51,52,53,54,42,52,53,54,55,43,53,54,55,56,44,54,55,56,57,45,55,56,57,58,53,63,64,65,66,54,64,65,66,67,55,65,66,67,68,56,66,67,68,69,57,67,68,69,70,65,75,76,77,78,66,76,77,78,79,67,77,78,79,80,68,78,79,80,81,69,79,80,81,82,77,87,88,89,90,78,88,89,90,91,79,89,90,91,92,80,90,91,92,93,81,91,92,93,94,89,99,100,101,102,90,100,101,102,103,91,101,102,103,104,92,102,103,104,105,93,103,104,105,106,102,112,113,114,115,103,113,114,115,116,104,114,115,116,117,28,39,40,41,42,29,40,41,42,43,30,41,42,43,44,31,42,43,44,45,32,43,44,45,46,40,51,52,53,54,41,52,53,54,55,42,53,54,55,56,43,54,55,56,57,44,55,56,57,58,52,63,64,65,66,53,64,65,66,67,54,65,66,67,68,55,66,67,68,69,56,67,68,69,70,64,75,76,77,78,65,76,77,78,79,66,77,78,79,80,67,78,79,80,81,68,79,80,81,82,76,87,88,89,90,77,88,89,90,91,78,89,90,91,92,79,90,91,92,93,80,91,92,93,94,88,99,100,101,102,89,100,101,102,103,90,101,102,103,104,91,102,103,104,105,92,103,104,105,106,101,112,113,114,115,102,113,114,115,116,103,114,115,116,117,28,39,40,52,64,29,40,41,53,65,30,41,42,54,66,31,42,43,55,67,32,43,44,56,68,33,44,45,57,69,40,51,52,64,76,41,52,53,65,77,42,53,54,66,78,43,54,55,67,79,44,55,56,68,80,45,56,57,69,81,46,57,58,70,82,52,63,64,76,88,53,64,65,77,89,54,65,66,78,90,55,66,67,79,91,56,67,68,80,92,57,68,69,81,93,58,69,70,82,94,64,75,76,88,100,65,76,77,89,101,66,77,78,90,102,67,78,79,91,103,68,79,80,92,104,69,80,81,93,105,70,81,82,94,106,76,87,88,100,112,77,88,89,101,113,78,89,90,102,114,79,90,91,103,115,80,91,92,104,116,81,92,93,105,117,28,40,41,52,64,29,41,42,53,65,30,42,43,54,66,31,43,44,55,67,32,44,45,56,68,33,45,46,57,69,39,51,52,63,75,40,52,53,64,76,41,53,54,65,77,42,54,55,66,78,43,55,56,67,79,44,56,57,68,80,45,57,58,69,81,51,63,64,75,87,52,64,65,76,88,53,65,66,77,89,54,66,67,78,90,55,67,68,79,91,56,68,69,80,92,57,69,70,81,93,63,75,76,87,99,64,76,77,88,100,65,77,78,89,101,66,78,79,90,102,67,79,80,91,103,68,80,81,92,104,69,81,82,93,105,76,88,89,100,112,77,89,90,101,113,78,90,91,102,114,79,91,92,103,115,80,92,93,104,116,81,93,94,105,117,28,40,51,52,64,29,41,52,53,65,30,42,53,54,66,31,43,54,55,67,32,44,55,56,68,33,45,56,57,69,40,52,63,64,76,41,53,64,65,77,42,54,65,66,78,43,55,66,67,79,44,56,67,68,80,45,57,68,69,81,46,58,69,70,82,52,64,75,76,88,53,65,76,77,89,54,66,77,78,90,55,67,78,79,91,56,68,79,80,92,57,69,80,81,93,58,70,81,82,94,64,76,87,88,100,65,77,88,89,101,66,78,89,90,102,67,79,90,91,103,68,80,91,92,104,69,81,92,93,105,70,82,93,94,106,76,88,99,100,112,77,89,100,101,113,78,90,101,102,114,79,91,102,103,115,80,92,103,104,116,81,93,104,105,117,28,40,52,53,64,29,41,53,54,65,30,42,54,55,66,31,43,55,56,67,32,44,56,57,68,33,45,57,58,69,39,51,63,64,75,40,52,64,65,76,41,53,65,66,77,42,54,66,67,78,43,55,67,68,79,44,56,68,69,80,45,57,69,70,81,51,63,75,76,87,52,64,76,77,88,53,65,77,78,89,54,66,78,79,90,55,67,79,80,91,56,68,80,81,92,57,69,81,82,93,63,75,87,88,99,64,76,88,89,100,65,77,89,90,101,66,78,90,91,102,67,79,91,92,103,68,80,92,93,104,69,81,93,94,105,76,88,100,101,112,77,89,101,102,113,78,90,102,103,114,79,91,103,104,115,80,92,104,105,116,81,93,105,106,117
};
for(int pi=0;pi<400; pi+=5)
{int pp1=pi,pp2=pi+1,pp3=pi+2,pp4=pi+3,pp5=pi+4;
int p1=p[pp1],p2=p[pp2],p3=p[pp3],p4=p[pp4],p5=p[pp5];
  if(
    p1==a1||p1==a2||p1==a3||p1==a4||p1==a5||
    p2==a1||p2==a2||p2==a3||p2==a4||p2==a5||
    p3==a1||p3==a2||p3==a3||p3==a4||p3==a5||
    p4==a1||p4==a2||p4==a3||p4==a4||p4==a5||
    p5==a1||p5==a2||p5==a3||p5==a4||p5==a5||
    p1==b1||p1==b2||p1==b3||p1==b4||p1==b5||
    p2==b1||p2==b2||p2==b3||p2==b4||p2==b5||
    p3==b1||p3==b2||p3==b3||p3==b4||p3==b5||
    p4==b1||p4==b2||p4==b3||p4==b4||p4==b5||
    p5==b1||p5==b2||p5==b3||p5==b4||p5==b5||
    p1==d1||p1==d2||p1==d3||p1==d4||p1==d5||
    p2==d1||p2==d2||p2==d3||p2==d4||p2==d5||
    p3==d1||p3==d2||p3==d3||p3==d4||p3==d5||
    p4==d1||p4==d2||p4==d3||p4==d4||p4==d5||
    p5==d1||p5==d2||p5==d3||p5==d4||p5==d5||
    p1==e1||p1==e2||p1==e3||p1==e4||p1==e5||
    p2==e1||p2==e2||p2==e3||p2==e4||p2==e5||
    p3==e1||p3==e2||p3==e3||p3==e4||p3==e5||
    p4==e1||p4==e2||p4==e3||p4==e4||p4==e5||
    p5==e1||p5==e2||p5==e3||p5==e4||p5==e5||
    p1==f1||p1==f2||p1==f3||p1==f4||p1==f5||
    p2==f1||p2==f2||p2==f3||p2==f4||p2==f5||
    p3==f1||p3==f2||p3==f3||p3==f4||p3==f5||
    p4==f1||p4==f2||p4==f3||p4==f4||p4==f5||
    p5==f1||p5==f2||p5==f3||p5==f4||p5==f5||
    p1==g1||p1==g2||p1==g3||p1==g4||p1==g5||
    p2==g1||p2==g2||p2==g3||p2==g4||p2==g5||
    p3==g1||p3==g2||p3==g3||p3==g4||p3==g5||
    p4==g1||p4==g2||p4==g3||p4==g4||p4==g5||
    p5==g1||p5==g2||p5==g3||p5==g4||p5==g5||
    p1==h1||p1==h2||p1==h3||p1==h4||p1==h5||
    p2==h1||p2==h2||p2==h3||p2==h4||p2==h5||
    p3==h1||p3==h2||p3==h3||p3==h4||p3==h5||
    p4==h1||p4==h2||p4==h3||p4==h4||p4==h5||
    p5==h1||p5==h2||p5==h3||p5==h4||p5==h5||
    p1==k1||p1==k2||p1==k3||p1==k4||p1==k5||
    p2==k1||p2==k2||p2==k3||p2==k4||p2==k5||
    p3==k1||p3==k2||p3==k3||p3==k4||p3==k5||
    p4==k1||p4==k2||p4==k3||p4==k4||p4==k5||
    p5==k1||p5==k2||p5==k3||p5==k4||p5==k5||
    p1==m1||p1==m2||p1==m3||p1==m4||p1==m5||
    p2==m1||p2==m2||p2==m3||p2==m4||p2==m5||
    p3==m1||p3==m2||p3==m3||p3==m4||p3==m5||
    p4==m1||p4==m2||p4==m3||p4==m4||p4==m5||
    p5==m1||p5==m2||p5==m3||p5==m4||p5==m5||
    p1==n1||p1==n2||p1==n3||p1==n4||p1==n5||
    p2==n1||p2==n2||p2==n3||p2==n4||p2==n5||
    p3==n1||p3==n2||p3==n3||p3==n4||p3==n5||
    p4==n1||p4==n2||p4==n3||p4==n4||p4==n5||
    p5==n1||p5==n2||p5==n3||p5==n4||p5==n5
    ) continue;
 //a
int r[]={28,39,40,41,52,30,41,42,43,54,31,42,43,44,55,33,44,45,46,57,41,52,53,54,65,42,53,54,55,66,43,54,55,56,67,44,55,56,57,68,52,63,64,65,76,53,64,65,66,77,54,65,66,67,78,55,66,67,68,79,56,67,68,69,80,57,68,69,70,81,64,75,76,77,88,65,76,77,78,89,66,77,78,79,90,67,78,79,80,91,68,79,80,81,92,69,80,81,82,93,77,88,89,90,101,78,89,90,91,102,79,90,91,92,103,80,91,92,93,104,88,99,100,101,112,90,101,102,103,114,91,102,103,104,115,93,104,105,106,117
 
};
for(int ri=0;ri<140; ri+=5)
{int rr1=ri,rr2=ri+1,rr3=ri+2,rr4=ri+3,rr5=ri+4;
int r1=r[rr1],r2=r[rr2],r3=r[rr3],r4=r[rr4],r5=r[rr5];
if(
    r1==a1||r1==a2||r1==a3||r1==a4||r1==a5||
    r2==a1||r2==a2||r2==a3||r2==a4||r2==a5||
    r3==a1||r3==a2||r3==a3||r3==a4||r3==a5||
    r4==a1||r4==a2||r4==a3||r4==a4||r4==a5||
    r5==a1||r5==a2||r5==a3||r5==a4||r5==a5||
    r1==b1||r1==b2||r1==b3||r1==b4||r1==b5||
    r2==b1||r2==b2||r2==b3||r2==b4||r2==b5||
    r3==b1||r3==b2||r3==b3||r3==b4||r3==b5||
    r4==b1||r4==b2||r4==b3||r4==b4||r4==b5||
    r5==b1||r5==b2||r5==b3||r5==b4||r5==b5||
    r1==d1||r1==d2||r1==d3||r1==d4||r1==d5||
    r2==d1||r2==d2||r2==d3||r2==d4||r2==d5||
    r3==d1||r3==d2||r3==d3||r3==d4||r3==d5||
    r4==d1||r4==d2||r4==d3||r4==d4||r4==d5||
    r5==d1||r5==d2||r5==d3||r5==d4||r5==d5||
    r1==e1||r1==e2||r1==e3||r1==e4||r1==e5||
    r2==e1||r2==e2||r2==e3||r2==e4||r2==e5||
    r3==e1||r3==e2||r3==e3||r3==e4||r3==e5||
    r4==e1||r4==e2||r4==e3||r4==e4||r4==e5||
    r5==e1||r5==e2||r5==e3||r5==e4||r5==e5||
    r1==f1||r1==f2||r1==f3||r1==f4||r1==f5||
    r2==f1||r2==f2||r2==f3||r2==f4||r2==f5||
    r3==f1||r3==f2||r3==f3||r3==f4||r3==f5||
    r4==f1||r4==f2||r4==f3||r4==f4||r4==f5||
    r5==f1||r5==f2||r5==f3||r5==f4||r5==f5||
    r1==g1||r1==g2||r1==g3||r1==g4||r1==g5||
    r2==g1||r2==g2||r2==g3||r2==g4||r2==g5||
    r3==g1||r3==g2||r3==g3||r3==g4||r3==g5||
    r4==g1||r4==g2||r4==g3||r4==g4||r4==g5||
    r5==g1||r5==g2||r5==g3||r5==g4||r5==g5||
    r1==h1||r1==h2||r1==h3||r1==h4||r1==h5||
    r2==h1||r2==h2||r2==h3||r2==h4||r2==h5||
    r3==h1||r3==h2||r3==h3||r3==h4||r3==h5||
    r4==h1||r4==h2||r4==h3||r4==h4||r4==h5||
    r5==h1||r5==h2||r5==h3||r5==h4||r5==h5||
    r1==k1||r1==k2||r1==k3||r1==k4||r1==k5||
    r2==k1||r2==k2||r2==k3||r2==k4||r2==k5||
    r3==k1||r3==k2||r3==k3||r3==k4||r3==k5||
    r4==k1||r4==k2||r4==k3||r4==k4||r4==k5||
    r5==k1||r5==k2||r5==k3||r5==k4||r5==k5||
    r1==m1||r1==m2||r1==m3||r1==m4||r1==m5||
    r2==m1||r2==m2||r2==m3||r2==m4||r2==m5||
    r3==m1||r3==m2||r3==m3||r3==m4||r3==m5||
    r4==m1||r4==m2||r4==m3||r4==m4||r4==m5||
    r5==m1||r5==m2||r5==m3||r5==m4||r5==m5||
    r1==n1||r1==n2||r1==n3||r1==n4||r1==n5||
    r2==n1||r2==n2||r2==n3||r2==n4||r2==n5||
    r3==n1||r3==n2||r3==n3||r3==n4||r3==n5||
    r4==n1||r4==n2||r4==n3||r4==n4||r4==n5||
    r5==n1||r5==n2||r5==n3||r5==n4||r5==n5||
    r1==p1||r1==p2||r1==p3||r1==p4||r1==p5||
    r2==p1||r2==p2||r2==p3||r2==p4||r2==p5||
    r3==p1||r3==p2||r3==p3||r3==p4||r3==p5||
    r4==p1||r4==p2||r4==p3||r4==p4||r4==p5||
    r5==p1||r5==p2||r5==p3||r5==p4||r5==p5
    ) continue;
 cout 
 <<a1<<","<<a2<<","<<a3<<","<<a4<<","<<a5<<"," <<b1<<","<<b2<<","<<b3<<","<<b4<<","<<b5<<"," <<d1<<","<<d2<<","<<d3<<","<<d4<<","<<d5<<","
 <<e1<<","<<e2<<","<<e3<<","<<e4<<","<<e5<<"," <<f1<<","<<f2<<","<<f3<<","<<f4<<","<<f5<<"," <<g1<<","<<g2<<","<<g3<<","<<g4<<","<<g5<<","
 <<h1<<","<<h2<<","<<h3<<","<<h4<<","<<h5<<"," <<k1<<","<<k2<<","<<k3<<","<<k4<<","<<k5<<"," <<m1<<","<<m2<<","<<m3<<","<<m4<<","<<m5<<","
 <<n1<<","<<n2<<","<<n3<<","<<n4<<","<<n5<<"," <<p1<<","<<p2<<","<<p3<<","<<p4<<","<<p5<<"," <<r1<<","<<r2<<","<<r3<<","<<r4<<","<<r5<<","
  <<x++<<endl;  
    
}}}}}}}}}}}}}   
system("pause");
return 0;
        }
Similar
Эксперт
41792 / 34177 / 6122
Регистрация: 12.04.2006
Сообщений: 57,940
13.02.2013, 13:38     Программа Пентамино
Посмотрите здесь:

C++ Ведется набор цифр и надо чтобы программа из него сама сообразило число. То есть что бы программа сама раскидывала их по разрядам.
C++ Пользователь вводит 10 чисел программа должна выдать 2 максимальных(берём от 1 до 10,если выпадает 2 10,то программа должна выдать 2 10,а не 10,9)

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
После регистрации реклама в сообщениях будет скрыта и будут доступны все возможности форума.
Issues
13.02.2013, 13:42
  #2

Не по теме:

ну и код...

paserge
-3 / 0 / 0
Регистрация: 16.01.2013
Сообщений: 42
13.02.2013, 13:51  [ТС]     Программа Пентамино #3
Краткое описание программы для понимания.
В Пентамино есть 12 фигурок и 63 варианта с учетом поворотов фигурок.
Я представил каждую фигурку в виде числового массива итого 12 масссивов.
Алгоритм сравнивает все пятерки чисел между 12 массивами на несовпадение отбрасывая в процессе расчета заведомо ложные ветки.
paserge
-3 / 0 / 0
Регистрация: 16.01.2013
Сообщений: 42
19.02.2013, 11:27  [ТС]     Программа Пентамино #4
изменил код программы но возникла другая трудность, использование continue перебрасывает в начало первого цикла а мне необходимо чтобы продолжить цикл
вот код:

C++
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
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip>
using namespace std; 
int main()
{
int x=1, ai=0, bi=0, di=0, ei=0, fi=0, gi=0, hi=0, ki=0, mi=0, ni=0, pi=0, ri=0;
long long y=0; int z[128]={0};
int z1=0,z2=0,z3=0,z4=0,z5=0,z6=0,z7=0,z8=0,z9=0,z10=0,z11=0,z12=0,z13=0,z14=0,z15=0,z16=0,z17=0,z18=0,z19=0,z20=0,z21=0,z22=0,z23=0,z24=0,z25=0,z26=0,z27=0,z28=0,z29=0,z30=0,z31=0,z32=0,z33=0,z34=0,z35=0,z36=0,z37=0,z38=0,z39=0,z40=0,z41=0,z42=0,z43=0,z44=0,z45=0,z46=0,z47=0,z48=0,z49=0,z50=0,z51=0,z52=0,z53=0,z54=0,z55=0,z56=0,z57=0,z58=0,z59=0,z60=0;
int a[]={
28,39,40,41,52,30,41,42,43,54,31,42,43,44,55,33,44,45,46,57,41,52,53,54,65,42,53,54,55,66,43,54,55,56,67,44,55,56,57,68,52,63,64,65,76,53,64,65,66,77,54,65,66,67,78,55,66,67,68,79,56,67,68,69,80,57,68,69,70,81,64,75,76,77,88,65,76,77,78,89,66,77,78,79,90,67,78,79,80,91,68,79,80,81,92,69,80,81,82,93,77,88,89,90,101,78,89,90,91,102,79,90,91,92,103,80,91,92,93,104,88,99,100,101,112,90,101,102,103,114,91,102,103,104,115,93,104,105,106,117
};
for(int ai=0;ai<140; ai+=5)
{
y++;int aa1=ai,aa2=ai+1,aa3=ai+2,aa4=ai+3,aa5=ai+4;
int a1=a[aa1],a2=a[aa2],a3=a[aa3],a4=a[aa4],a5=a[aa5];
z1=a1-1,z2=a2-1,z3=a3-1,z4=a4-1,z5=a5-1;
if(z[z1]==1 || z[z2]==1 ||z[z3]==1 ||z[z4]==1 ||z[z5]==1)continue;
 else {z[z1]=1, z[z2]=1, z[z3]=1, z[z4]=1,z[z5]=1;}
 system ("pause");cout<<"a"<<a1<<","<<a2<<","<<a3<<","<<a4<<","<<a5<<";"<<endl;
int b[]={
28,29,30,31,32,29,30,31,32,33,51,52,53,54,55,52,53,54,55,56,53,54,55,56,57,54,55,56,57,58,63,64,65,66,67,64,65,66,67,68,65,66,67,68,69,66,67,68,69,70,75,76,77,78,79,76,77,78,79,80,77,78,79,80,81,78,79,80,81,82,87,88,89,90,91,88,89,90,91,92,89,90,91,92,93,90,91,92,93,94,112,113,114,115,116,113,114,115,116,117,29,41,53,65,77,30,42,54,66,78,31,43,55,67,79,32,44,56,68,80,39,51,63,75,87,41,53,65,77,89,42,54,66,78,90,43,55,67,79,91,44,56,68,80,92,46,58,70,82,94,51,63,75,87,99,53,65,77,89,101,54,66,78,90,102,55,67,79,91,103,56,68,80,92,104,58,70,82,94,106,65,77,89,101,113,66,78,90,102,114,67,79,91,103,115,68,80,92,104,116
};
for(int bi=0;bi<200; bi+=5)
{
y++;int bb1=bi,bb2=bi+1,bb3=bi+2,bb4=bi+3,bb5=bi+4;
int b1=b[bb1],b2=b[bb2],b3=b[bb3],b4=b[bb4],b5=b[bb5];
 
z6=b1-1,z7=b2-1,z8=b3-1,z9=b4-1,z10=b5-1;
if(z[z6]==1 || z[z7]==1 ||z[z8]==1 ||z[z9]==1 ||z[z10]==1)continue;
 else {z[z6]=1, z[z7]=1, z[z8]=1, z[z9]=1,z[z10]=1;}
 system ("pause");cout<<"b"<<b1<<","<<b2<<","<<b3<<","<<b4<<","<<b5<<";"<<endl;
if(bi==200){z[z1]=0,z[z2]=0,z[z3]=0,z[z4]=0,z[z5]=0;}
 
int d[]={
28,29,30,40,42,29,30,31,41,43,30,31,32,42,44,31,32,33,43,45,39,40,41,51,53,40,41,42,52,54,41,42,43,53,55,42,43,44,54,56,43,44,45,55,57,44,45,46,56,58,51,52,53,63,65,52,53,54,64,66,53,54,55,65,67,54,55,56,66,68,55,56,57,67,69,56,57,58,68,70,63,64,65,75,77,64,65,66,76,78,65,66,67,77,79,66,67,68,78,80,67,68,69,79,81,68,69,70,80,82,75,76,77,87,89,76,77,78,88,90,77,78,79,89,91,78,79,80,90,92,79,80,81,91,93,80,81,82,92,94,87,88,89,99,101,88,89,90,100,102,89,90,91,101,103,90,91,92,102,104,91,92,93,103,105,92,93,94,104,106,28,29,40,52,53,29,30,41,53,54,30,31,42,54,55,31,32,43,55,56,32,33,44,56,57,39,40,51,63,64,40,41,52,64,65,41,42,53,65,66,42,43,54,66,67,43,44,55,67,68,44,45,56,68,69,51,52,63,75,76,52,53,64,76,77,53,54,65,77,78,54,55,66,78,79,55,56,67,79,80,56,57,68,80,81,63,64,75,87,88,64,65,76,88,89,65,66,77,89,90,66,67,78,90,91,67,68,79,91,92,68,69,80,92,93,75,76,87,99,100,76,77,88,100,101,77,78,89,101,102,78,79,90,102,103,79,80,91,103,104,80,81,92,104,105,88,89,100,112,113,89,90,101,113,114,90,91,102,114,115,91,92,103,115,116,92,93,104,116,117,28,29,41,52,53,29,30,42,53,54,30,31,43,54,55,31,32,44,55,56,32,33,45,56,57,40,41,53,64,65,41,42,54,65,66,42,43,55,66,67,43,44,56,67,68,44,45,57,68,69,45,46,58,69,70,52,53,65,76,77,53,54,66,77,78,54,55,67,78,79,55,56,68,79,80,56,57,69,80,81,57,58,70,81,82,64,65,77,88,89,65,66,78,89,90,66,67,79,90,91,67,68,80,91,92,68,69,81,92,93,69,70,82,93,94,76,77,89,100,101,77,78,90,101,102,78,79,91,102,103,79,80,92,103,104,80,81,93,104,105,81,82,94,105,106,88,89,101,112,113,89,90,102,113,114,90,91,103,114,115,91,92,104,115,116,92,93,105,116,117,39,41,51,52,53,40,42,52,53,54,41,43,53,54,55,42,44,54,55,56,43,45,55,56,57,44,46,56,57,58,51,53,63,64,65,52,54,64,65,66,53,55,65,66,67,54,56,66,67,68,55,57,67,68,69,56,58,68,69,70,63,65,75,76,77,64,66,76,77,78,65,67,77,78,79,66,68,78,79,80,67,69,79,80,81,68,70,80,81,82,75,77,87,88,89,76,78,88,89,90,77,79,89,90,91,78,80,90,91,92,79,81,91,92,93,80,82,92,93,94,87,89,99,100,101,88,90,100,101,102,89,91,101,102,103,90,92,102,103,104,91,93,103,104,105,92,94,104,105,106,100,102,112,113,114,101,103,113,114,115,102,104,114,115,116,103,105,115,116,117
};
for(int di=0;di<680; di+=5) 
{
y++;int dd1=di,dd2=di+1,dd3=di+2,dd4=di+3,dd5=di+4;
int d1=d[dd1],d2=d[dd2],d3=d[dd3],d4=d[dd4],d5=d[dd5];
 
z11=d1-1,z12=d2-1,z13=d3-1,z14=d4-1,z15=d5-1;
if(z[z11]==1 || z[z12]==1 ||z[z13]==1 ||z[z14]==1 ||z[z15]==1)continue;
 else {z[z11]=1, z[z12]=1, z[z13]=1, z[z14]=1,z[z15]=1;}
 system ("pause");cout<<"d"<<d1<<","<<d2<<","<<d3<<","<<d4<<","<<d5<<";"<<endl;
if(di==680){z[z6]=0, z[z7]=0, z[z8]=0, z[z9]=0,z[z10]=0;}
 
 int e[]={
28,29,30,40,52,29,30,31,41,53,30,31,32,42,54,31,32,33,43,55,39,40,41,51,63,40,41,42,52,64,41,42,43,53,65,42,43,44,54,66,43,44,45,55,67,44,45,46,56,68,51,52,53,63,75,52,53,54,64,76,53,54,55,65,77,54,55,56,66,78,55,56,57,67,79,56,57,58,68,80,63,64,65,75,87,64,65,66,76,88,65,66,67,77,89,66,67,68,78,90,67,68,69,79,91,68,69,70,80,92,75,76,77,87,99,76,77,78,88,100,77,78,79,89,101,78,79,80,90,102,79,80,81,91,103,80,81,82,92,104,88,89,90,100,112,89,90,91,101,113,90,91,92,102,114,91,92,93,103,115,28,29,30,42,54,29,30,31,43,55,30,31,32,44,56,31,32,33,45,57,39,40,41,53,65,40,41,42,54,66,41,42,43,55,67,42,43,44,56,68,43,44,45,57,69,44,45,46,58,70,51,52,53,65,77,52,53,54,66,78,53,54,55,67,79,54,55,56,68,80,55,56,57,69,81,56,57,58,70,82,63,64,65,77,89,64,65,66,78,90,65,66,67,79,91,66,67,68,80,92,67,68,69,81,93,68,69,70,82,94,75,76,77,89,101,76,77,78,90,102,77,78,79,91,103,78,79,80,92,104,79,80,81,93,105,80,81,82,94,106,88,89,90,102,114,89,90,91,103,115,90,91,92,104,116,91,92,93,105,117,30,42,52,53,54,31,43,53,54,55,32,44,54,55,56,33,45,55,56,57,41,53,63,64,65,42,54,64,65,66,43,55,65,66,67,44,56,66,67,68,45,57,67,68,69,46,58,68,69,70,53,65,75,76,77,54,66,76,77,78,55,67,77,78,79,56,68,78,79,80,57,69,79,80,81,58,70,80,81,82,65,77,87,88,89,66,78,88,89,90,67,79,89,90,91,68,80,90,91,92,69,81,91,92,93,70,82,92,93,94,77,89,99,100,101,78,90,100,101,102,79,91,101,102,103,80,92,102,103,104,81,93,103,104,105,82,94,104,105,106,90,102,112,113,114,91,103,113,114,115,92,104,114,115,116,93,105,115,116,117,28,40,52,53,54,29,41,53,54,55,30,42,54,55,56,31,43,55,56,57,39,51,63,64,65,40,52,64,65,66,41,53,65,66,67,42,54,66,67,68,43,55,67,68,69,44,56,68,69,70,51,63,75,76,77,52,64,76,77,78,53,65,77,78,79,54,66,78,79,80,55,67,79,80,81,56,68,80,81,82,63,75,87,88,89,64,76,88,89,90,65,77,89,90,91,66,78,90,91,92,67,79,91,92,93,68,80,92,93,94,75,87,99,100,101,76,88,100,101,102,77,89,101,102,103,78,90,102,103,104,79,91,103,104,105,80,92,104,105,106,88,100,112,113,114,89,101,113,114,115,90,102,114,115,116,91,103,115,116,117
};
for(int ei=0;ei<640; ei+=5)
{
y++;int ee1=ei,ee2=ei+1,ee3=ei+2,ee4=ei+3,ee5=ei+4;
int e1=e[ee1],e2=e[ee2],e3=e[ee3],e4=e[ee4],e5=e[ee5];
 
z16=e1-1,z17=e2-1,z18=e3-1,z19=e4-1,z20=e5-1;
if(z[z16]==1 || z[z17]==1 ||z[z18]==1 ||z[z19]==1 ||z[z20]==1)continue;
 else {z[z16]=1, z[z17]=1, z[z18]=1, z[z19]=1,z[z20]=1;}
 system ("pause");cout<<"e"<<e1<<","<<e2<<","<<e3<<","<<e4<<","<<e5<<";"<<endl;
if(ei==640){z[z11]=0, z[z12]=0, z[z13]=0, z[z14]=0,z[z15]=0;}
 
int f[]={
28,29,41,42,54,29,30,42,43,55,30,31,43,44,56,32,33,45,46,58,39,40,52,53,65,40,41,53,54,66,41,42,54,55,67,42,43,55,56,68,43,44,56,57,69,51,52,64,65,77,52,53,65,66,78,53,54,66,67,79,54,55,67,68,80,55,56,68,69,81,56,57,69,70,82,63,64,76,77,89,64,65,77,78,90,65,66,78,79,91,66,67,79,80,92,67,68,80,81,93,68,69,81,82,94,76,77,89,90,102,77,78,90,91,103,78,79,91,92,104,79,80,92,93,105,80,81,93,94,106,89,90,102,103,115,90,91,103,104,116,91,92,104,105,117,28,29,39,40,51,30,31,41,42,53,31,32,42,43,54,32,33,43,44,55,41,42,52,53,64,42,43,53,54,65,43,44,54,55,66,44,45,55,56,67,45,46,56,57,68,52,53,63,64,75,53,54,64,65,76,54,55,65,66,77,55,56,66,67,78,56,57,67,68,79,57,58,68,69,80,64,65,75,76,87,65,66,76,77,88,66,67,77,78,89,67,68,78,79,90,68,69,79,80,91,69,70,80,81,92,76,77,87,88,99,77,78,88,89,100,78,79,89,90,101,79,80,90,91,102,80,81,91,92,103,89,90,100,101,112,90,91,101,102,113,91,92,102,103,114,31,42,43,53,54,32,43,44,54,55,33,44,45,55,56,42,53,54,64,65,43,54,55,65,66,44,55,56,66,67,45,56,57,67,68,46,57,58,68,69,53,64,65,75,76,54,65,66,76,77,55,66,67,77,78,56,67,68,78,79,57,68,69,79,80,58,69,70,80,81,65,76,77,87,88,66,77,78,88,89,67,78,79,89,90,68,79,80,90,91,69,80,81,91,92,70,81,82,92,93,77,88,89,99,100,78,89,90,100,101,79,90,91,101,102,80,91,92,102,103,81,92,93,103,104,90,101,102,112,113,91,102,103,113,114,92,103,104,114,115,94,105,106,116,117,28,40,41,53,54,29,41,42,54,55,30,42,43,55,56,39,51,52,64,65,40,52,53,65,66,41,53,54,66,67,42,54,55,67,68,43,55,56,68,69,51,63,64,76,77,52,64,65,77,78,53,65,66,78,79,54,66,67,79,80,55,67,68,80,81,56,68,69,81,82,63,75,76,88,89,64,76,77,89,90,65,77,78,90,91,66,78,79,91,92,67,79,80,92,93,68,80,81,93,94,76,88,89,101,102,77,89,90,102,103,78,90,91,103,104,79,91,92,104,105,80,92,93,105,106,87,99,100,112,113,89,101,102,114,115,90,102,103,115,116,91,103,104,116,117
};
for(int fi=0;fi<580; fi+=5)
{
y++;int ff1=fi,ff2=fi+1,ff3=fi+2,ff4=fi+3,ff5=fi+4;
int f1=f[ff1],f2=f[ff2],f3=f[ff3],f4=f[ff4],f5=f[ff5];
 
z21=f1-1,z22=f2-1,z23=f3-1,z24=f4-1,z25=f5-1;
if(z[z21]==1 || z[z22]==1 ||z[z23]==1 ||z[z24]==1 ||z[z25]==1)continue;
 else {z[z21]=1, z[z22]=1, z[z23]=1, z[z24]=1,z[z25]=1;}
 system ("pause");cout<<"f"<<f1<<","<<f2<<","<<f3<<","<<f4<<","<<f5<<";"<<endl;
 if(fi==580){z[z16]=0, z[z17]=0, z[z18]=0, z[z19]=0,z[z20]=0;}
 
 int g[]={
29,30,41,52,53,30,31,42,53,54,31,32,43,54,55,32,33,44,55,56,40,41,52,63,64,41,42,53,64,65,42,43,54,65,66,43,44,55,66,67,44,45,56,67,68,45,46,57,68,69,52,53,64,75,76,53,54,65,76,77,54,55,66,77,78,55,56,67,78,79,56,57,68,79,80,57,58,69,80,81,64,65,76,87,88,65,66,77,88,89,66,67,78,89,90,67,68,79,90,91,68,69,80,91,92,69,70,81,92,93,76,77,88,99,100,77,78,89,100,101,78,79,90,101,102,79,80,91,102,103,80,81,92,103,104,81,82,93,104,105,89,90,101,112,113,90,91,102,113,114,91,92,103,114,115,92,93,104,115,116,28,29,41,53,54,29,30,42,54,55,30,31,43,55,56,31,32,44,56,57,39,40,52,64,65,40,41,53,65,66,41,42,54,66,67,42,43,55,67,68,43,44,56,68,69,44,45,57,69,70,51,52,64,76,77,52,53,65,77,78,53,54,66,78,79,54,55,67,79,80,55,56,68,80,81,56,57,69,81,82,63,64,76,88,89,64,65,77,89,90,65,66,78,90,91,66,67,79,91,92,67,68,80,92,93,68,69,81,93,94,75,76,88,100,101,76,77,89,101,102,77,78,90,102,103,78,79,91,103,104,79,80,92,104,105,80,81,93,105,106,88,89,101,113,114,89,90,102,114,115,90,91,103,115,116,91,92,104,116,117,30,40,41,42,52,31,41,42,43,53,32,42,43,44,54,33,43,44,45,55,41,51,52,53,63,42,52,53,54,64,43,53,54,55,65,44,54,55,56,66,45,55,56,57,67,46,56,57,58,68,53,63,64,65,75,54,64,65,66,76,55,65,66,67,77,56,66,67,68,78,57,67,68,69,79,58,68,69,70,80,65,75,76,77,87,66,76,77,78,88,67,77,78,79,89,68,78,79,80,90,69,79,80,81,91,70,80,81,82,92,77,87,88,89,99,78,88,89,90,100,79,89,90,91,101,80,90,91,92,102,81,91,92,93,103,82,92,93,94,104,90,100,101,102,112,91,101,102,103,113,92,102,103,104,114,93,103,104,105,115,28,40,41,42,54,29,41,42,43,55,30,42,43,44,56,31,43,44,45,57,39,51,52,53,65,40,52,53,54,66,41,53,54,55,67,42,54,55,56,68,43,55,56,57,69,44,56,57,58,70,51,63,64,65,77,52,64,65,66,78,53,65,66,67,79,54,66,67,68,80,55,67,68,69,81,56,68,69,70,82,63,75,76,77,89,64,76,77,78,90,65,77,78,79,91,66,78,79,80,92,67,79,80,81,93,68,80,81,82,94,75,87,88,89,101,76,88,89,90,102,77,89,90,91,103,78,90,91,92,104,79,91,92,93,105,80,92,93,94,106,88,100,101,102,114,89,101,102,103,115,90,102,103,104,116,91,103,104,105,117
};
for(int gi=0;gi<640; gi+=5)
{
y++;int gg1=gi,gg2=gi+1,gg3=gi+2,gg4=gi+3,gg5=gi+4;
int g1=g[gg1],g2=g[gg2],g3=g[gg3],g4=g[gg4],g5=g[gg5];
 
z26=g1-1,z27=g2-1,z28=g3-1,z29=g4-1,z30=g5-1;
if(z[z26]==1 || z[z27]==1 ||z[z28]==1 ||z[z29]==1 ||z[z30]==1)continue;
 else {z[z26]=1, z[z27]=1, z[z28]=1, z[z29]=1,z[z30]=1;}
 system ("pause");cout<<"g"<<g1<<","<<g2<<","<<g3<<","<<g4<<","<<g5<<";"<<endl;
 if(gi==640){z[z21]=0, z[z22]=0, z[z23]=0, z[z24]=0,z[z25]=0;}
 
int h[]={
28,29,30,41,53,29,30,31,42,54,30,31,32,43,55,31,32,33,44,56,39,40,41,52,64,40,41,42,53,65,41,42,43,54,66,42,43,44,55,67,43,44,45,56,68,44,45,46,57,69,51,52,53,64,76,52,53,54,65,77,53,54,55,66,78,54,55,56,67,79,55,56,57,68,80,56,57,58,69,81,63,64,65,76,88,64,65,66,77,89,65,66,67,78,90,66,67,68,79,91,67,68,69,80,92,68,69,70,81,93,75,76,77,88,100,76,77,78,89,101,77,78,79,90,102,78,79,80,91,103,79,80,81,92,104,80,81,82,93,105,87,88,89,100,112,88,89,90,101,113,89,90,91,102,114,90,91,92,103,115,91,92,93,104,116,92,93,94,105,117,29,39,40,41,53,30,40,41,42,54,31,41,42,43,55,32,42,43,44,56,33,43,44,45,57,41,51,52,53,65,42,52,53,54,66,43,53,54,55,67,44,54,55,56,68,45,55,56,57,69,46,56,57,58,70,53,63,64,65,77,54,64,65,66,78,55,65,66,67,79,56,66,67,68,80,57,67,68,69,81,58,68,69,70,82,65,75,76,77,89,66,76,77,78,90,67,77,78,79,91,68,78,79,80,92,69,79,80,81,93,70,80,81,82,94,77,87,88,89,101,78,88,89,90,102,79,89,90,91,103,80,90,91,92,104,81,91,92,93,105,82,92,93,94,106,89,99,100,101,113,90,100,101,102,114,91,101,102,103,115,92,102,103,104,116,93,103,104,105,117,28,40,41,42,52,29,41,42,43,53,30,42,43,44,54,31,43,44,45,55,32,44,45,46,56,39,51,52,53,63,40,52,53,54,64,41,53,54,55,65,42,54,55,56,66,43,55,56,57,67,44,56,57,58,68,51,63,64,65,75,52,64,65,66,76,53,65,66,67,77,54,66,67,68,78,55,67,68,69,79,56,68,69,70,80,63,75,76,77,87,64,76,77,78,88,65,77,78,79,89,66,78,79,80,90,67,79,80,81,91,68,80,81,82,92,75,87,88,89,99,76,88,89,90,100,77,89,90,91,101,78,90,91,92,102,79,91,92,93,103,80,92,93,94,104,88,100,101,102,112,89,101,102,103,113,90,102,103,104,114,91,103,104,105,115,92,104,105,106,116,28,40,51,52,53,29,41,52,53,54,30,42,53,54,55,31,43,54,55,56,32,44,55,56,57,33,45,56,57,58,40,52,63,64,65,41,53,64,65,66,42,54,65,66,67,43,55,66,67,68,44,56,67,68,69,45,57,68,69,70,52,64,75,76,77,53,65,76,77,78,54,66,77,78,79,55,67,78,79,80,56,68,79,80,81,57,69,80,81,82,64,76,87,88,89,65,77,88,89,90,66,78,89,90,91,67,79,90,91,92,68,80,91,92,93,69,81,92,93,94,76,88,99,100,101,77,89,100,101,102,78,90,101,102,103,79,91,102,103,104,80,92,103,104,105,81,93,104,105,106,89,101,112,113,114,90,102,113,114,115,91,103,114,115,116,92,104,115,116,117
};
for(int hi=0;hi<680; hi+=5)
{
y++;int hh1=hi,hh2=hi+1,hh3=hi+2,hh4=hi+3,hh5=hi+4;
int h1=h[hh1],h2=h[hh2],h3=h[hh3],h4=h[hh4],h5=h[hh5];
 
z31=h1-1,z32=h2-1,z33=h3-1,z34=h4-1,z35=h5-1;
if(z[z31]==1 || z[z32]==1 ||z[z33]==1 ||z[z34]==1 ||z[z35]==1)continue;
 else {z[z31]=1, z[z32]=1, z[z33]=1, z[z34]=1,z[z35]=1;}
 system ("pause");cout<<"h"<<h1<<","<<h2<<","<<h3<<","<<h4<<","<<h5<<";"<<endl;
 if(hi==680){z[z26]=0, z[z27]=0, z[z28]=0, z[z29]=0,z[z30]=0;}
 
int k[]={
28,29,30,40,41,29,30,31,41,42,30,31,32,42,43,31,32,33,43,44,39,40,41,51,52,40,41,42,52,53,41,42,43,53,54,42,43,44,54,55,43,44,45,55,56,44,45,46,56,57,51,52,53,63,64,52,53,54,64,65,53,54,55,65,66,54,55,56,66,67,55,56,57,67,68,56,57,58,68,69,63,64,65,75,76,64,65,66,76,77,65,66,67,77,78,66,67,68,78,79,67,68,69,79,80,68,69,70,80,81,75,76,77,87,88,76,77,78,88,89,77,78,79,89,90,78,79,80,90,91,79,80,81,91,92,80,81,82,92,93,87,88,89,99,100,88,89,90,100,101,89,90,91,101,102,90,91,92,102,103,91,92,93,103,104,92,93,94,104,105,100,101,102,112,113,101,102,103,113,114,102,103,104,114,115,103,104,105,115,116,104,105,106,116,117,28,29,30,41,42,29,30,31,42,43,30,31,32,43,44,31,32,33,44,45,39,40,41,52,53,40,41,42,53,54,41,42,43,54,55,42,43,44,55,56,43,44,45,56,57,44,45,46,57,58,51,52,53,64,65,52,53,54,65,66,53,54,55,66,67,54,55,56,67,68,55,56,57,68,69,56,57,58,69,70,63,64,65,76,77,64,65,66,77,78,65,66,67,78,79,66,67,68,79,80,67,68,69,80,81,68,69,70,81,82,75,76,77,88,89,76,77,78,89,90,77,78,79,90,91,78,79,80,91,92,79,80,81,92,93,80,81,82,93,94,87,88,89,100,101,88,89,90,101,102,89,90,91,102,103,90,91,92,103,104,91,92,93,104,105,92,93,94,105,106,99,100,101,112,113,100,101,102,113,114,101,102,103,114,115,102,103,104,115,116,103,104,105,116,117,28,29,39,40,41,29,30,40,41,42,30,31,41,42,43,31,32,42,43,44,32,33,43,44,45,40,41,51,52,53,41,42,52,53,54,42,43,53,54,55,43,44,54,55,56,44,45,55,56,57,45,46,56,57,58,52,53,63,64,65,53,54,64,65,66,54,55,65,66,67,55,56,66,67,68,56,57,67,68,69,57,58,68,69,70,64,65,75,76,77,65,66,76,77,78,66,67,77,78,79,67,68,78,79,80,68,69,79,80,81,69,70,80,81,82,76,77,87,88,89,77,78,88,89,90,78,79,89,90,91,79,80,90,91,92,80,81,91,92,93,81,82,92,93,94,88,89,99,100,101,89,90,100,101,102,90,91,101,102,103,91,92,102,103,104,92,93,103,104,105,93,94,104,105,106,101,102,112,113,114,102,103,113,114,115,103,104,114,115,116,104,105,115,116,117,28,29,40,41,42,29,30,41,42,43,30,31,42,43,44,31,32,43,44,45,32,33,44,45,46,39,40,51,52,53,40,41,52,53,54,41,42,53,54,55,42,43,54,55,56,43,44,55,56,57,44,45,56,57,58,51,52,63,64,65,52,53,64,65,66,53,54,65,66,67,54,55,66,67,68,55,56,67,68,69,56,57,68,69,70,63,64,75,76,77,64,65,76,77,78,65,66,77,78,79,66,67,78,79,80,67,68,79,80,81,68,69,80,81,82,75,76,87,88,89,76,77,88,89,90,77,78,89,90,91,78,79,90,91,92,79,80,91,92,93,80,81,92,93,94,87,88,99,100,101,88,89,100,101,102,89,90,101,102,103,90,91,102,103,104,91,92,103,104,105,92,93,104,105,106,100,101,112,113,114,101,102,113,114,115,102,103,114,115,116,103,104,115,116,117,28,29,40,41,52,29,30,41,42,53,30,31,42,43,54,31,32,43,44,55,32,33,44,45,56,39,40,51,52,63,40,41,52,53,64,41,42,53,54,65,42,43,54,55,66,43,44,55,56,67,44,45,56,57,68,45,46,57,58,69,51,52,63,64,75,52,53,64,65,76,53,54,65,66,77,54,55,66,67,78,55,56,67,68,79,56,57,68,69,80,57,58,69,70,81,63,64,75,76,87,64,65,76,77,88,65,66,77,78,89,66,67,78,79,90,67,68,79,80,91,68,69,80,81,92,69,70,81,82,93,75,76,87,88,99,76,77,88,89,100,77,78,89,90,101,78,79,90,91,102,79,80,91,92,103,80,81,92,93,104,81,82,93,94,105,88,89,100,101,112,89,90,101,102,113,90,91,102,103,114,91,92,103,104,115,92,93,104,105,116,93,94,105,106,117,28,29,40,41,53,29,30,41,42,54,30,31,42,43,55,31,32,43,44,56,32,33,44,45,57,39,40,51,52,64,40,41,52,53,65,41,42,53,54,66,42,43,54,55,67,43,44,55,56,68,44,45,56,57,69,45,46,57,58,70,51,52,63,64,76,52,53,64,65,77,53,54,65,66,78,54,55,66,67,79,55,56,67,68,80,56,57,68,69,81,57,58,69,70,82,63,64,75,76,88,64,65,76,77,89,65,66,77,78,90,66,67,78,79,91,67,68,79,80,92,68,69,80,81,93,69,70,81,82,94,75,76,87,88,100,76,77,88,89,101,77,78,89,90,102,78,79,90,91,103,79,80,91,92,104,80,81,92,93,105,81,82,93,94,106,87,88,99,100,112,88,89,100,101,113,89,90,101,102,114,90,91,102,103,115,91,92,103,104,116,92,93,104,105,117,28,39,40,51,52,29,40,41,52,53,30,41,42,53,54,31,42,43,54,55,32,43,44,55,56,33,44,45,56,57,40,51,52,63,64,41,52,53,64,65,42,53,54,65,66,43,54,55,66,67,44,55,56,67,68,45,56,57,68,69,46,57,58,69,70,52,63,64,75,76,53,64,65,76,77,54,65,66,77,78,55,66,67,78,79,56,67,68,79,80,57,68,69,80,81,58,69,70,81,82,64,75,76,87,88,65,76,77,88,89,66,77,78,89,90,67,78,79,90,91,68,79,80,91,92,69,80,81,92,93,70,81,82,93,94,76,87,88,99,100,77,88,89,100,101,78,89,90,101,102,79,90,91,102,103,80,91,92,103,104,81,92,93,104,105,82,93,94,105,106,89,100,101,112,113,90,101,102,113,114,91,102,103,114,115,92,103,104,115,116,93,104,105,116,117,28,40,41,52,53,29,41,42,53,54,30,42,43,54,55,31,43,44,55,56,32,44,45,56,57,33,45,46,57,58,39,51,52,63,64,40,52,53,64,65,41,53,54,65,66,42,54,55,66,67,43,55,56,67,68,44,56,57,68,69,45,57,58,69,70,51,63,64,75,76,52,64,65,76,77,53,65,66,77,78,54,66,67,78,79,55,67,68,79,80,56,68,69,80,81,57,69,70,81,82,63,75,76,87,88,64,76,77,88,89,65,77,78,89,90,66,78,79,90,91,67,79,80,91,92,68,80,81,92,93,69,81,82,93,94,75,87,88,99,100,76,88,89,100,101,77,89,90,101,102,78,90,91,102,103,79,91,92,103,104,80,92,93,104,105,81,93,94,105,106,88,100,101,112,113,89,101,102,113,114,90,102,103,114,115,91,103,104,115,116,92,104,105,116,117
};
for(int ki=0;ki<1560; ki+=5)    
{
y++;int kk1=ki,kk2=ki+1,kk3=ki+2,kk4=ki+3,kk5=ki+4;
int k1=k[kk1],k2=k[kk2],k3=k[kk3],k4=k[kk4],k5=k[kk5];
 
z36=k1-1,z37=k2-1,z38=k3-1,z39=k4-1,z40=k5-1;
if(z[z36]==1 || z[z37]==1 ||z[z38]==1 ||z[z39]==1 ||z[z40]==1)continue;
 else {z[z36]=1, z[z37]=1, z[z38]=1, z[z39]=1,z[z40]=1;}
 system ("pause");cout<<"k"<<k1<<","<<k2<<","<<k3<<","<<k4<<","<<k5<<";"<<endl;
 if(ki==1560){z[z31]=0, z[z32]=0, z[z33]=0, z[z34]=0,z[z35]=0;}
 
int m[]={
28,29,39,40,52,29,30,40,41,53,30,31,41,42,54,31,32,42,43,55,32,33,43,44,56,40,41,51,52,64,41,42,52,53,65,42,43,53,54,66,43,44,54,55,67,44,45,55,56,68,45,46,56,57,69,52,53,63,64,76,53,54,64,65,77,54,55,65,66,78,55,56,66,67,79,56,57,67,68,80,57,58,68,69,81,64,65,75,76,88,65,66,76,77,89,66,67,77,78,90,67,68,78,79,91,68,69,79,80,92,69,70,80,81,93,76,77,87,88,100,77,78,88,89,101,78,79,89,90,102,79,80,90,91,103,80,81,91,92,104,81,82,92,93,105,88,89,99,100,112,89,90,100,101,113,90,91,101,102,114,91,92,102,103,115,92,93,103,104,116,93,94,104,105,117,28,29,41,42,53,29,30,42,43,54,30,31,43,44,55,31,32,44,45,56,32,33,45,46,57,39,40,52,53,64,40,41,53,54,65,41,42,54,55,66,42,43,55,56,67,43,44,56,57,68,44,45,57,58,69,51,52,64,65,76,52,53,65,66,77,53,54,66,67,78,54,55,67,68,79,55,56,68,69,80,56,57,69,70,81,63,64,76,77,88,64,65,77,78,89,65,66,78,79,90,66,67,79,80,91,67,68,80,81,92,68,69,81,82,93,75,76,88,89,100,76,77,89,90,101,77,78,90,91,102,78,79,91,92,103,79,80,92,93,104,80,81,93,94,105,87,88,100,101,112,88,89,101,102,113,89,90,102,103,114,90,91,103,104,115,91,92,104,105,116,92,93,105,106,117,29,39,40,41,52,30,40,41,42,53,31,41,42,43,54,32,42,43,44,55,33,43,44,45,56,41,51,52,53,64,42,52,53,54,65,43,53,54,55,66,44,54,55,56,67,45,55,56,57,68,46,56,57,58,69,53,63,64,65,76,54,64,65,66,77,55,65,66,67,78,56,66,67,68,79,57,67,68,69,80,58,68,69,70,81,65,75,76,77,88,66,76,77,78,89,67,77,78,79,90,68,78,79,80,91,69,79,80,81,92,70,80,81,82,93,77,87,88,89,100,78,88,89,90,101,79,89,90,91,102,80,90,91,92,103,81,91,92,93,104,82,92,93,94,105,89,99,100,101,112,90,100,101,102,113,91,101,102,103,114,92,102,103,104,115,93,103,104,105,116,94,104,105,106,117,28,39,40,41,51,29,40,41,42,52,30,41,42,43,53,31,42,43,44,54,32,43,44,45,55,33,44,45,46,56,40,51,52,53,63,41,52,53,54,64,42,53,54,55,65,43,54,55,56,66,44,55,56,57,67,45,56,57,58,68,52,63,64,65,75,53,64,65,66,76,54,65,66,67,77,55,66,67,68,78,56,67,68,69,79,57,68,69,70,80,64,75,76,77,87,65,76,77,78,88,66,77,78,79,89,67,78,79,80,90,68,79,80,81,91,69,80,81,82,92,76,87,88,89,99,77,88,89,90,100,78,89,90,91,101,79,90,91,92,102,80,91,92,93,103,81,92,93,94,104,89,100,101,102,112,90,101,102,103,113,91,102,103,104,114,92,103,104,105,115,93,104,105,106,116,28,39,40,41,53,29,40,41,42,54,30,41,42,43,55,31,42,43,44,56,32,43,44,45,57,33,44,45,46,58,40,51,52,53,65,41,52,53,54,66,42,53,54,55,67,43,54,55,56,68,44,55,56,57,69,45,56,57,58,70,52,63,64,65,77,53,64,65,66,78,54,65,66,67,79,55,66,67,68,80,56,67,68,69,81,57,68,69,70,82,64,75,76,77,89,65,76,77,78,90,66,77,78,79,91,67,78,79,80,92,68,79,80,81,93,69,80,81,82,94,76,87,88,89,101,77,88,89,90,102,78,89,90,91,103,79,90,91,92,104,80,91,92,93,105,81,92,93,94,106,88,99,100,101,113,89,100,101,102,114,90,101,102,103,115,91,102,103,104,116,92,103,104,105,117,28,39,40,52,53,29,40,41,53,54,30,41,42,54,55,31,42,43,55,56,32,43,44,56,57,33,44,45,57,58,40,51,52,64,65,41,52,53,65,66,42,53,54,66,67,43,54,55,67,68,44,55,56,68,69,45,56,57,69,70,52,63,64,76,77,53,64,65,77,78,54,65,66,78,79,55,66,67,79,80,56,67,68,80,81,57,68,69,81,82,64,75,76,88,89,65,76,77,89,90,66,77,78,90,91,67,78,79,91,92,68,79,80,92,93,69,80,81,93,94,76,87,88,100,101,77,88,89,101,102,78,89,90,102,103,79,90,91,103,104,80,91,92,104,105,81,92,93,105,106,88,99,100,112,113,89,100,101,113,114,90,101,102,114,115,91,102,103,115,116,92,103,104,116,117,28,40,41,42,53,29,41,42,43,54,30,42,43,44,55,31,43,44,45,56,32,44,45,46,57,39,51,52,53,64,40,52,53,54,65,41,53,54,55,66,42,54,55,56,67,43,55,56,57,68,44,56,57,58,69,51,63,64,65,76,52,64,65,66,77,53,65,66,67,78,54,66,67,68,79,55,67,68,69,80,56,68,69,70,81,63,75,76,77,88,64,76,77,78,89,65,77,78,79,90,66,78,79,80,91,67,79,80,81,92,68,80,81,82,93,75,87,88,89,100,76,88,89,90,101,77,89,90,91,102,78,90,91,92,103,79,91,92,93,104,80,92,93,94,105,87,99,100,101,112,88,100,101,102,113,89,101,102,103,114,90,102,103,104,115,91,103,104,105,116,92,104,105,106,117,28,40,41,51,52,29,41,42,52,53,30,42,43,53,54,31,43,44,54,55,32,44,45,55,56,33,45,46,56,57,40,52,53,63,64,41,53,54,64,65,42,54,55,65,66,43,55,56,66,67,44,56,57,67,68,45,57,58,68,69,52,64,65,75,76,53,65,66,76,77,54,66,67,77,78,55,67,68,78,79,56,68,69,79,80,57,69,70,80,81,64,76,77,87,88,65,77,78,88,89,66,78,79,89,90,67,79,80,90,91,68,80,81,91,92,69,81,82,92,93,76,88,89,99,100,77,89,90,100,101,78,90,91,101,102,79,91,92,102,103,80,92,93,103,104,81,93,94,104,105,89,101,102,112,113,90,102,103,113,114,91,103,104,114,115,92,104,105,115,116,93,105,106,116,117
};
for(int mi=0;mi<1400; mi+=5)
{
y++;int mm1=mi,mm2=mi+1,mm3=mi+2,mm4=mi+3,mm5=mi+4;
int m1=m[mm1],m2=m[mm2],m3=m[mm3],m4=m[mm4],m5=m[mm5];
 
z41=m1-1,z42=m2-1,z43=m3-1,z44=m4-1,z45=m5-1;
if(z[z41]==1 || z[z42]==1 ||z[z43]==1 ||z[z44]==1 ||z[z45]==1)continue;
 else {z[z41]=1, z[z42]=1, z[z43]=1, z[z44]=1,z[z45]=1;}
 system ("pause");cout<<"m"<<m1<<","<<m2<<","<<m3<<","<<m4<<","<<m5<<";"<<endl;
if(mi==1400){z[z36]=0, z[z37]=0, z[z38]=0, z[z39]=0,z[z40]=0;}
 
int n[]={
28,29,30,31,40,29,30,31,32,41,30,31,32,33,42,39,40,41,42,51,40,41,42,43,52,41,42,43,44,53,42,43,44,45,54,43,44,45,46,55,51,52,53,54,63,52,53,54,55,64,53,54,55,56,65,54,55,56,57,66,55,56,57,58,67,63,64,65,66,75,64,65,66,67,76,65,66,67,68,77,66,67,68,69,78,67,68,69,70,79,75,76,77,78,87,76,77,78,79,88,77,78,79,80,89,78,79,80,81,90,79,80,81,82,91,87,88,89,90,99,88,89,90,91,100,89,90,91,92,101,90,91,92,93,102,91,92,93,94,103,100,101,102,103,112,101,102,103,104,113,102,103,104,105,114,103,104,105,106,115,28,29,30,31,43,29,30,31,32,44,30,31,32,33,45,39,40,41,42,54,40,41,42,43,55,41,42,43,44,56,42,43,44,45,57,43,44,45,46,58,51,52,53,54,66,52,53,54,55,67,53,54,55,56,68,54,55,56,57,69,55,56,57,58,70,63,64,65,66,78,64,65,66,67,79,65,66,67,68,80,66,67,68,69,81,67,68,69,70,82,75,76,77,78,90,76,77,78,79,91,77,78,79,80,92,78,79,80,81,93,79,80,81,82,94,87,88,89,90,102,88,89,90,91,103,89,90,91,92,104,90,91,92,93,105,91,92,93,94,106,99,100,101,102,114,100,101,102,103,115,101,102,103,104,116,102,103,104,105,117,30,39,40,41,42,31,40,41,42,43,32,41,42,43,44,33,42,43,44,45,42,51,52,53,54,43,52,53,54,55,44,53,54,55,56,45,54,55,56,57,46,55,56,57,58,54,63,64,65,66,55,64,65,66,67,56,65,66,67,68,57,66,67,68,69,58,67,68,69,70,66,75,76,77,78,67,76,77,78,79,68,77,78,79,80,69,78,79,80,81,70,79,80,81,82,78,87,88,89,90,79,88,89,90,91,80,89,90,91,92,81,90,91,92,93,82,91,92,93,94,90,99,100,101,102,91,100,101,102,103,92,101,102,103,104,93,102,103,104,105,94,103,104,105,106,103,112,113,114,115,104,113,114,115,116,105,114,115,116,117,28,40,41,42,43,29,41,42,43,44,30,42,43,44,45,31,43,44,45,46,39,51,52,53,54,40,52,53,54,55,41,53,54,55,56,42,54,55,56,57,43,55,56,57,58,51,63,64,65,66,52,64,65,66,67,53,65,66,67,68,54,66,67,68,69,55,67,68,69,70,63,75,76,77,78,64,76,77,78,79,65,77,78,79,80,66,78,79,80,81,67,79,80,81,82,75,87,88,89,90,76,88,89,90,91,77,89,90,91,92,78,90,91,92,93,79,91,92,93,94,87,99,100,101,102,88,100,101,102,103,89,101,102,103,104,90,102,103,104,105,91,103,104,105,106,100,112,113,114,115,101,113,114,115,116,102,114,115,116,117,28,29,40,52,64,29,30,41,53,65,30,31,42,54,66,31,32,43,55,67,32,33,44,56,68,39,40,51,63,75,40,41,52,64,76,41,42,53,65,77,42,43,54,66,78,43,44,55,67,79,44,45,56,68,80,45,46,57,69,81,51,52,63,75,87,52,53,64,76,88,53,54,65,77,89,54,55,66,78,90,55,56,67,79,91,56,57,68,80,92,57,58,69,81,93,63,64,75,87,99,64,65,76,88,100,65,66,77,89,101,66,67,78,90,102,67,68,79,91,103,68,69,80,92,104,69,70,81,93,105,76,77,88,100,112,77,78,89,101,113,78,79,90,102,114,79,80,91,103,115,80,81,92,104,116,81,82,93,105,117,28,29,41,53,65,29,30,42,54,66,30,31,43,55,67,31,32,44,56,68,32,33,45,57,69,39,40,52,64,76,40,41,53,65,77,41,42,54,66,78,42,43,55,67,79,43,44,56,68,80,44,45,57,69,81,45,46,58,70,82,51,52,64,76,88,52,53,65,77,89,53,54,66,78,90,54,55,67,79,91,55,56,68,80,92,56,57,69,81,93,57,58,70,82,94,63,64,76,88,100,64,65,77,89,101,65,66,78,90,102,66,67,79,91,103,67,68,80,92,104,68,69,81,93,105,69,70,82,94,106,75,76,88,100,112,76,77,89,101,113,77,78,90,102,114,78,79,91,103,115,79,80,92,104,116,80,81,93,105,117,28,40,52,63,64,29,41,53,64,65,30,42,54,65,66,31,43,55,66,67,32,44,56,67,68,33,45,57,68,69,40,52,64,75,76,41,53,65,76,77,42,54,66,77,78,43,55,67,78,79,44,56,68,79,80,45,57,69,80,81,46,58,70,81,82,52,64,76,87,88,53,65,77,88,89,54,66,78,89,90,55,67,79,90,91,56,68,80,91,92,57,69,81,92,93,58,70,82,93,94,64,76,88,99,100,65,77,89,100,101,66,78,90,101,102,67,79,91,102,103,68,80,92,103,104,69,81,93,104,105,70,82,94,105,106,77,89,101,112,113,78,90,102,113,114,79,91,103,114,115,80,92,104,115,116,81,93,105,116,117,28,40,52,64,65,29,41,53,65,66,30,42,54,66,67,31,43,55,67,68,32,44,56,68,69,33,45,57,69,70,39,51,63,75,76,40,52,64,76,77,41,53,65,77,78,42,54,66,78,79,43,55,67,79,80,44,56,68,80,81,45,57,69,81,82,51,63,75,87,88,52,64,76,88,89,53,65,77,89,90,54,66,78,90,91,55,67,79,91,92,56,68,80,92,93,57,69,81,93,94,63,75,87,99,100,64,76,88,100,101,65,77,89,101,102,66,78,90,102,103,67,79,91,103,104,68,80,92,104,105,69,81,93,105,106,76,88,100,112,113,77,89,101,113,114,78,90,102,114,115,79,91,103,115,116,80,92,104,116,117
};
for(int ni=0;ni<1280; ni+=5)
{ 
y++;int nn1=ni,nn2=ni+1,nn3=ni+2,nn4=ni+3,nn5=ni+4;
int n1=n[nn1],n2=n[nn2],n3=n[nn3],n4=n[nn4],n5=n[nn5];
 
z46=n1-1,z47=n2-1,z48=n3-1,z49=n4-1,z50=n5-1;
if(z[z46]==1 || z[z47]==1 ||z[z48]==1 ||z[z49]==1 ||z[z50]==1)continue;
 else {z[z46]=1, z[z47]=1, z[z48]=1, z[z49]=1,z[z50]=1;}
 system ("pause");cout<<"n"<<n1<<","<<n2<<","<<n3<<","<<n4<<","<<n5<<";"<<endl;
if(ni==1280){z[z41]=0, z[z42]=0, z[z43]=0, z[z44]=0,z[z45]=0;} 
int p[]={
28,29,30,31,41,29,30,31,32,42,30,31,32,33,43,39,40,41,42,52,40,41,42,43,53,41,42,43,44,54,42,43,44,45,55,43,44,45,46,56,51,52,53,54,64,52,53,54,55,65,53,54,55,56,66,54,55,56,57,67,55,56,57,58,68,63,64,65,66,76,64,65,66,67,77,65,66,67,68,78,66,67,68,69,79,67,68,69,70,80,75,76,77,78,88,76,77,78,79,89,77,78,79,80,90,78,79,80,81,91,79,80,81,82,92,87,88,89,90,100,88,89,90,91,101,89,90,91,92,102,90,91,92,93,103,91,92,93,94,104,99,100,101,102,112,100,101,102,103,113,101,102,103,104,114,102,103,104,105,115,103,104,105,106,116,28,29,30,31,42,29,30,31,32,43,30,31,32,33,44,39,40,41,42,53,40,41,42,43,54,41,42,43,44,55,42,43,44,45,56,43,44,45,46,57,51,52,53,54,65,52,53,54,55,66,53,54,55,56,67,54,55,56,57,68,55,56,57,58,69,63,64,65,66,77,64,65,66,67,78,65,66,67,68,79,66,67,68,69,80,67,68,69,70,81,75,76,77,78,89,76,77,78,79,90,77,78,79,80,91,78,79,80,81,92,79,80,81,82,93,87,88,89,90,101,88,89,90,91,102,89,90,91,92,103,90,91,92,93,104,91,92,93,94,105,99,100,101,102,113,100,101,102,103,114,101,102,103,104,115,102,103,104,105,116,103,104,105,106,117,29,39,40,41,42,30,40,41,42,43,31,41,42,43,44,32,42,43,44,45,33,43,44,45,46,41,51,52,53,54,42,52,53,54,55,43,53,54,55,56,44,54,55,56,57,45,55,56,57,58,53,63,64,65,66,54,64,65,66,67,55,65,66,67,68,56,66,67,68,69,57,67,68,69,70,65,75,76,77,78,66,76,77,78,79,67,77,78,79,80,68,78,79,80,81,69,79,80,81,82,77,87,88,89,90,78,88,89,90,91,79,89,90,91,92,80,90,91,92,93,81,91,92,93,94,89,99,100,101,102,90,100,101,102,103,91,101,102,103,104,92,102,103,104,105,93,103,104,105,106,102,112,113,114,115,103,113,114,115,116,104,114,115,116,117,28,39,40,41,42,29,40,41,42,43,30,41,42,43,44,31,42,43,44,45,32,43,44,45,46,40,51,52,53,54,41,52,53,54,55,42,53,54,55,56,43,54,55,56,57,44,55,56,57,58,52,63,64,65,66,53,64,65,66,67,54,65,66,67,68,55,66,67,68,69,56,67,68,69,70,64,75,76,77,78,65,76,77,78,79,66,77,78,79,80,67,78,79,80,81,68,79,80,81,82,76,87,88,89,90,77,88,89,90,91,78,89,90,91,92,79,90,91,92,93,80,91,92,93,94,88,99,100,101,102,89,100,101,102,103,90,101,102,103,104,91,102,103,104,105,92,103,104,105,106,101,112,113,114,115,102,113,114,115,116,103,114,115,116,117,28,39,40,52,64,29,40,41,53,65,30,41,42,54,66,31,42,43,55,67,32,43,44,56,68,33,44,45,57,69,40,51,52,64,76,41,52,53,65,77,42,53,54,66,78,43,54,55,67,79,44,55,56,68,80,45,56,57,69,81,46,57,58,70,82,52,63,64,76,88,53,64,65,77,89,54,65,66,78,90,55,66,67,79,91,56,67,68,80,92,57,68,69,81,93,58,69,70,82,94,64,75,76,88,100,65,76,77,89,101,66,77,78,90,102,67,78,79,91,103,68,79,80,92,104,69,80,81,93,105,70,81,82,94,106,76,87,88,100,112,77,88,89,101,113,78,89,90,102,114,79,90,91,103,115,80,91,92,104,116,81,92,93,105,117,28,40,41,52,64,29,41,42,53,65,30,42,43,54,66,31,43,44,55,67,32,44,45,56,68,33,45,46,57,69,39,51,52,63,75,40,52,53,64,76,41,53,54,65,77,42,54,55,66,78,43,55,56,67,79,44,56,57,68,80,45,57,58,69,81,51,63,64,75,87,52,64,65,76,88,53,65,66,77,89,54,66,67,78,90,55,67,68,79,91,56,68,69,80,92,57,69,70,81,93,63,75,76,87,99,64,76,77,88,100,65,77,78,89,101,66,78,79,90,102,67,79,80,91,103,68,80,81,92,104,69,81,82,93,105,76,88,89,100,112,77,89,90,101,113,78,90,91,102,114,79,91,92,103,115,80,92,93,104,116,81,93,94,105,117,28,40,51,52,64,29,41,52,53,65,30,42,53,54,66,31,43,54,55,67,32,44,55,56,68,33,45,56,57,69,40,52,63,64,76,41,53,64,65,77,42,54,65,66,78,43,55,66,67,79,44,56,67,68,80,45,57,68,69,81,46,58,69,70,82,52,64,75,76,88,53,65,76,77,89,54,66,77,78,90,55,67,78,79,91,56,68,79,80,92,57,69,80,81,93,58,70,81,82,94,64,76,87,88,100,65,77,88,89,101,66,78,89,90,102,67,79,90,91,103,68,80,91,92,104,69,81,92,93,105,70,82,93,94,106,76,88,99,100,112,77,89,100,101,113,78,90,101,102,114,79,91,102,103,115,80,92,103,104,116,81,93,104,105,117,28,40,52,53,64,29,41,53,54,65,30,42,54,55,66,31,43,55,56,67,32,44,56,57,68,33,45,57,58,69,39,51,63,64,75,40,52,64,65,76,41,53,65,66,77,42,54,66,67,78,43,55,67,68,79,44,56,68,69,80,45,57,69,70,81,51,63,75,76,87,52,64,76,77,88,53,65,77,78,89,54,66,78,79,90,55,67,79,80,91,56,68,80,81,92,57,69,81,82,93,63,75,87,88,99,64,76,88,89,100,65,77,89,90,101,66,78,90,91,102,67,79,91,92,103,68,80,92,93,104,69,81,93,94,105,76,88,100,101,112,77,89,101,102,113,78,90,102,103,114,79,91,103,104,115,80,92,104,105,116,81,93,105,106,117
};
for(int pi=0;pi<1320; pi+=5)
{
y++;int pp1=pi,pp2=pi+1,pp3=pi+2,pp4=pi+3,pp5=pi+4;
int p1=p[pp1],p2=p[pp2],p3=p[pp3],p4=p[pp4],p5=p[pp5];
 
z51=p1-1,z52=p2-1,z53=p3-1,z54=p4-1,z55=p5-1;
if(z[z51]==1 || z[z52]==1 ||z[z53]==1 ||z[z54]==1 ||z[z55]==1)continue;
 else {z[z51]=1, z[z52]=1, z[z53]=1, z[z54]=1,z[z55]=1;}
 system ("pause");cout<<"p"<<p2<<","<<p3<<","<<p4<<","<<p5<<";"<<endl;
 if(pi==1320){z[z46]=0, z[z47]=0, z[z48]=0, z[z49]=0,z[z50]=0;}
  
int r[]={
28,29,30,39,40,29,30,31,40,41,30,31,32,41,42,31,32,33,42,43,40,41,42,51,52,41,42,43,52,53,42,43,44,53,54,43,44,45,54,55,44,45,46,55,56,52,53,54,63,64,53,54,55,64,65,54,55,56,65,66,55,56,57,66,67,56,57,58,67,68,64,65,66,75,76,65,66,67,76,77,66,67,68,77,78,67,68,69,78,79,68,69,70,79,80,76,77,78,87,88,77,78,79,88,89,78,79,80,89,90,79,80,81,90,91,80,81,82,91,92,88,89,90,99,100,89,90,91,100,101,90,91,92,101,102,91,92,93,102,103,92,93,94,103,104,101,102,103,112,113,102,103,104,113,114,103,104,105,114,115,104,105,106,115,116,28,29,30,42,43,29,30,31,43,44,30,31,32,44,45,31,32,33,45,46,39,40,41,53,54,40,41,42,54,55,41,42,43,55,56,42,43,44,56,57,43,44,45,57,58,51,52,53,65,66,52,53,54,66,67,53,54,55,67,68,54,55,56,68,69,55,56,57,69,70,63,64,65,77,78,64,65,66,78,79,65,66,67,79,80,66,67,68,80,81,67,68,69,81,82,75,76,77,89,90,76,77,78,90,91,77,78,79,91,92,78,79,80,92,93,79,80,81,93,94,87,88,89,101,102,88,89,90,102,103,89,90,91,103,104,90,91,92,104,105,91,92,93,105,106,99,100,101,113,114,100,101,102,114,115,101,102,103,115,116,102,103,104,116,117,29,30,39,40,41,30,31,40,41,42,31,32,41,42,43,32,33,42,43,44,41,42,51,52,53,42,43,52,53,54,43,44,53,54,55,44,45,54,55,56,45,46,55,56,57,53,54,63,64,65,54,55,64,65,66,55,56,65,66,67,56,57,66,67,68,57,58,67,68,69,65,66,75,76,77,66,67,76,77,78,67,68,77,78,79,68,69,78,79,80,69,70,79,80,81,77,78,87,88,89,78,79,88,89,90,79,80,89,90,91,80,81,90,91,92,81,82,91,92,93,89,90,99,100,101,90,91,100,101,102,91,92,101,102,103,92,93,102,103,104,93,94,103,104,105,102,103,112,113,114,103,104,113,114,115,104,105,114,115,116,105,106,115,116,117,28,29,41,42,43,29,30,42,43,44,30,31,43,44,45,31,32,44,45,46,39,40,52,53,54,40,41,53,54,55,41,42,54,55,56,42,43,55,56,57,43,44,56,57,58,51,52,64,65,66,52,53,65,66,67,53,54,66,67,68,54,55,67,68,69,55,56,68,69,70,63,64,76,77,78,64,65,77,78,79,65,66,78,79,80,66,67,79,80,81,67,68,80,81,82,75,76,88,89,90,76,77,89,90,91,77,78,90,91,92,78,79,91,92,93,79,80,92,93,94,87,88,100,101,102,88,89,101,102,103,89,90,102,103,104,90,91,103,104,105,91,92,104,105,106,99,100,112,113,114,100,101,113,114,115,101,102,114,115,116,102,103,115,116,117,28,39,40,51,63,29,40,41,52,64,30,41,42,53,65,31,42,43,54,66,32,43,44,55,67,33,44,45,56,68,40,51,52,63,75,41,52,53,64,76,42,53,54,65,77,43,54,55,66,78,44,55,56,67,79,45,56,57,68,80,46,57,58,69,81,52,63,64,75,87,53,64,65,76,88,54,65,66,77,89,55,66,67,78,90,56,67,68,79,91,57,68,69,80,92,58,69,70,81,93,64,75,76,87,99,65,76,77,88,100,66,77,78,89,101,67,78,79,90,102,68,79,80,91,103,69,80,81,92,104,70,81,82,93,105,77,88,89,100,112,78,89,90,101,113,79,90,91,102,114,80,91,92,103,115,81,92,93,104,116,82,93,94,105,117,28,40,41,53,65,29,41,42,54,66,30,42,43,55,67,31,43,44,56,68,32,44,45,57,69,33,45,46,58,70,39,51,52,64,76,40,52,53,65,77,41,53,54,66,78,42,54,55,67,79,43,55,56,68,80,44,56,57,69,81,45,57,58,70,82,51,63,64,76,88,52,64,65,77,89,53,65,66,78,90,54,66,67,79,91,55,67,68,80,92,56,68,69,81,93,57,69,70,82,94,63,75,76,88,100,64,76,77,89,101,65,77,78,90,102,66,78,79,91,103,67,79,80,92,104,68,80,81,93,105,69,81,82,94,106,75,87,88,100,112,76,88,89,101,113,77,89,90,102,114,78,90,91,103,115,79,91,92,104,116,80,92,93,105,117,28,40,51,52,63,29,41,52,53,64,30,42,53,54,65,31,43,54,55,66,32,44,55,56,67,33,45,56,57,68,40,52,63,64,75,41,53,64,65,76,42,54,65,66,77,43,55,66,67,78,44,56,67,68,79,45,57,68,69,80,46,58,69,70,81,52,64,75,76,87,53,65,76,77,88,54,66,77,78,89,55,67,78,79,90,56,68,79,80,91,57,69,80,81,92,58,70,81,82,93,64,76,87,88,99,65,77,88,89,100,66,78,89,90,101,67,79,90,91,102,68,80,91,92,103,69,81,92,93,104,70,82,93,94,105,77,89,100,101,112,78,90,101,102,113,79,91,102,103,114,80,92,103,104,115,81,93,104,105,116,82,94,105,106,117,28,40,52,53,65
};
for(int ri=0;ri<1160; ri+=5)
{y++;int rr1=ri,rr2=ri+1,rr3=ri+2,rr4=ri+3,rr5=ri+4;
int r1=r[rr1],r2=r[rr2],r3=r[rr3],r4=r[rr4],r5=r[rr5];
z56=r1-1,z57=r2-1,z58=r3-1,z59=r4-1,z60=r5-1;
if(z[z56]==1 || z[z57]==1 ||z[z58]==1 ||z[z59]==1 ||z[z60]==1)continue;
   system ("pause");cout 
 <<a1<<","<<a2<<","<<a3<<","<<a4<<","<<a5<<";" <<b1<<","<<b2<<","<<b3<<","<<b4<<","<<b5<<";" <<d1<<","<<d2<<","<<d3<<","<<d4<<","<<d5<<";"
 <<e1<<","<<e2<<","<<e3<<","<<e4<<","<<e5<<";" <<f1<<","<<f2<<","<<f3<<","<<f4<<","<<f5<<";" <<g1<<","<<g2<<","<<g3<<","<<g4<<","<<g5<<";"
 <<h1<<","<<h2<<","<<h3<<","<<h4<<","<<h5<<";" <<k1<<","<<k2<<","<<k3<<","<<k4<<","<<k5<<";" <<m1<<","<<m2<<","<<m3<<","<<m4<<","<<m5<<";"
 <<n1<<","<<n2<<","<<n3<<","<<n4<<","<<n5<<";" <<p1<<","<<p2<<","<<p3<<","<<p4<<","<<p5<<";" <<r1<<","<<r2<<","<<r3<<","<<r4<<","<<r5<<";"
  <<x++<<";"<<y<<endl;
  z[z56]=0, z[z57]=0, z[z58]=0, z[z59]=0,z[z60]=0; 
  z[z51]=0, z[z52]=0, z[z53]=0, z[z54]=0, z[z55]=0; 
    
}}}}}}}}}}}}    
system ("pause");
return 0;
        }
кто что может посоветовать?
MrGrig
176 / 159 / 2
Регистрация: 08.10.2012
Сообщений: 422
19.02.2013, 13:13     Программа Пентамино #5
Вы знаете, прочитав задание я больше чем уверен что нужно решать её через рекурсивные функции. чтобы оптимизировать ваш код, его, к сожалению, нужно переписать с нуля =с
paserge
-3 / 0 / 0
Регистрация: 16.01.2013
Сообщений: 42
19.02.2013, 15:34  [ТС]     Программа Пентамино #6
Переделал код но возникла другая сложность есть вложенные циклы for

вот пример
for(ai=0;ai<1000; ai+=5)
{условие1
for(bi=0;bi<500; bi+=5)
{условие2
for(di=0;di<700; di+=5)
{
}}}

необходимо чтобы
условие1 выполнялось при выходе из цикла for (bi ,
условие2 выполнялось при выходе из цикла for (di ,

к сожалению при выходе из цикла for (bi , происходит онуление bi
а при выходе из цикла for (di , происходит онуление bi

еслиб это не происходило то моя программа бы работала нормально
вот код с возможностью увидеть результат обработки:

Кликните здесь для просмотра всего текста
C++ (Qt)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip>
using namespace std; 
int main()
{
int x=1, ai=0, bi=0, di=0, ei=0, fi=0, gi=0, hi=0, ki=0, mi=0, ni=0, pi=0, ri=0;
long long y=0; int z[128]={0};
int z1=0,z2=0,z3=0,z4=0,z5=0,z6=0,z7=0,z8=0,z9=0,z10=0,z11=0,z12=0,z13=0,z14=0,z15=0,z16=0,z17=0,z18=0,z19=0,z20=0,z21=0,z22=0,z23=0,z24=0,z25=0,z26=0,z27=0,z28=0,z29=0,z30=0,z31=0,z32=0,z33=0,z34=0,z35=0,z36=0,z37=0,z38=0,z39=0,z40=0,z41=0,z42=0,z43=0,z44=0,z45=0,z46=0,z47=0,z48=0,z49=0,z50=0,z51=0,z52=0,z53=0,z54=0,z55=0,z56=0,z57=0,z58=0,z59=0,z60=0;
int a[]={
28,39,40,41,52,30,41,42,43,54,31,42,43,44,55,33,44,45,46,57,41,52,53,54,65,42,53,54,55,66,43,54,55,56,67,44,55,56,57,68,52,63,64,65,76,53,64,65,66,77,54,65,66,67,78,55,66,67,68,79,56,67,68,69,80,57,68,69,70,81,64,75,76,77,88,65,76,77,78,89,66,77,78,79,90,67,78,79,80,91,68,79,80,81,92,69,80,81,82,93,77,88,89,90,101,78,89,90,91,102,79,90,91,92,103,80,91,92,93,104,88,99,100,101,112,90,101,102,103,114,91,102,103,104,115,93,104,105,106,117
};
for(int ai=0;ai<140; ai+=5)
{if(bi==200){z[z1]=0,z[z2]=0,z[z3]=0,z[z4]=0,z[z5]=0;z[z6]=0, z[z7]=0, z[z8]=0, z[z9]=0,z[z10]=0;continue;}
y++;int aa1=ai,aa2=ai+1,aa3=ai+2,aa4=ai+3,aa5=ai+4;
int a1=a[aa1],a2=a[aa2],a3=a[aa3],a4=a[aa4],a5=a[aa5];
z1=a1-1,z2=a2-1,z3=a3-1,z4=a4-1,z5=a5-1;
if(z[z1]>0 || z[z2]>0 ||z[z3]>0 ||z[z4]>0 ||z[z5]>0)continue;
 else {z[z1]=1, z[z2]=1, z[z3]=1, z[z4]=1,z[z5]=1;}
 system ("pause");
 cout<<"a"<<ai<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl
<<"|"<<" "<<z[27]<<z[28]<<z[29]<<z[30]<<z[31]<<z[32]<<" "<<"|"<<endl
<<"|"<<z[38]<<z[39]<<z[40]<<z[41]<<z[42]<<z[43]<<z[44]<<z[45]<<"|"<<endl
<<"|"<<z[50]<<z[51]<<z[52]<<z[53]<<z[54]<<z[55]<<z[56]<<z[57]<<"|"<<endl
<<"|"<<z[62]<<z[63]<<z[64]<<z[65]<<z[66]<<z[67]<<z[68]<<z[69]<<"|"<<endl
<<"|"<<z[74]<<z[75]<<z[76]<<z[77]<<z[78]<<z[79]<<z[80]<<z[81]<<"|"<<endl
<<"|"<<z[86]<<z[87]<<z[88]<<z[89]<<z[90]<<z[91]<<z[92]<<z[93]<<"|"<<endl
<<"|"<<z[98]<<z[99]<<z[100]<<z[101]<<z[102]<<z[103]<<z[104]<<z[105]<<"|"<<endl
<<"|"<<" "<<z[111]<<z[112]<<z[113]<<z[114]<<z[115]<<z[116]<<" "<<"|"<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl;
int b[]={
28,29,30,31,32,29,30,31,32,33,51,52,53,54,55,52,53,54,55,56,53,54,55,56,57,54,55,56,57,58,63,64,65,66,67,64,65,66,67,68,65,66,67,68,69,66,67,68,69,70,75,76,77,78,79,76,77,78,79,80,77,78,79,80,81,78,79,80,81,82,87,88,89,90,91,88,89,90,91,92,89,90,91,92,93,90,91,92,93,94,112,113,114,115,116,113,114,115,116,117,29,41,53,65,77,30,42,54,66,78,31,43,55,67,79,32,44,56,68,80,39,51,63,75,87,41,53,65,77,89,42,54,66,78,90,43,55,67,79,91,44,56,68,80,92,46,58,70,82,94,51,63,75,87,99,53,65,77,89,101,54,66,78,90,102,55,67,79,91,103,56,68,80,92,104,58,70,82,94,106,65,77,89,101,113,66,78,90,102,114,67,79,91,103,115,68,80,92,104,116
};
for(int bi=0;bi<200; bi+=5)
{if(di==680){z[z1]=0,z[z2]=0,z[z3]=0,z[z4]=0,z[z5]=0;z[z6]=0, z[z7]=0, z[z8]=0, z[z9]=0,z[z10]=0;continue;}
    
y++;int bb1=bi,bb2=bi+1,bb3=bi+2,bb4=bi+3,bb5=bi+4;
int b1=b[bb1],b2=b[bb2],b3=b[bb3],b4=b[bb4],b5=b[bb5];
 
z6=b1-1,z7=b2-1,z8=b3-1,z9=b4-1,z10=b5-1;
 
if(z[z6]>0 || z[z7]>0 ||z[z8]>0 ||z[z9]>0 ||z[z10]>0)continue;
 else {z[z6]=2, z[z7]=2, z[z8]=2, z[z9]=2,z[z10]=2;}
 system ("pause"); cout<<"b"<<bi<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl
<<"|"<<" "<<z[27]<<z[28]<<z[29]<<z[30]<<z[31]<<z[32]<<" "<<"|"<<endl
<<"|"<<z[38]<<z[39]<<z[40]<<z[41]<<z[42]<<z[43]<<z[44]<<z[45]<<"|"<<endl
<<"|"<<z[50]<<z[51]<<z[52]<<z[53]<<z[54]<<z[55]<<z[56]<<z[57]<<"|"<<endl
<<"|"<<z[62]<<z[63]<<z[64]<<z[65]<<z[66]<<z[67]<<z[68]<<z[69]<<"|"<<endl
<<"|"<<z[74]<<z[75]<<z[76]<<z[77]<<z[78]<<z[79]<<z[80]<<z[81]<<"|"<<endl
<<"|"<<z[86]<<z[87]<<z[88]<<z[89]<<z[90]<<z[91]<<z[92]<<z[93]<<"|"<<endl
<<"|"<<z[98]<<z[99]<<z[100]<<z[101]<<z[102]<<z[103]<<z[104]<<z[105]<<"|"<<endl
<<"|"<<" "<<z[111]<<z[112]<<z[113]<<z[114]<<z[115]<<z[116]<<" "<<"|"<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl;
 
int d[]={
28,29,30,40,42,29,30,31,41,43,30,31,32,42,44,31,32,33,43,45,39,40,41,51,53,40,41,42,52,54,41,42,43,53,55,42,43,44,54,56,43,44,45,55,57,44,45,46,56,58,51,52,53,63,65,52,53,54,64,66,53,54,55,65,67,54,55,56,66,68,55,56,57,67,69,56,57,58,68,70,63,64,65,75,77,64,65,66,76,78,65,66,67,77,79,66,67,68,78,80,67,68,69,79,81,68,69,70,80,82,75,76,77,87,89,76,77,78,88,90,77,78,79,89,91,78,79,80,90,92,79,80,81,91,93,80,81,82,92,94,87,88,89,99,101,88,89,90,100,102,89,90,91,101,103,90,91,92,102,104,91,92,93,103,105,92,93,94,104,106,28,29,40,52,53,29,30,41,53,54,30,31,42,54,55,31,32,43,55,56,32,33,44,56,57,39,40,51,63,64,40,41,52,64,65,41,42,53,65,66,42,43,54,66,67,43,44,55,67,68,44,45,56,68,69,51,52,63,75,76,52,53,64,76,77,53,54,65,77,78,54,55,66,78,79,55,56,67,79,80,56,57,68,80,81,63,64,75,87,88,64,65,76,88,89,65,66,77,89,90,66,67,78,90,91,67,68,79,91,92,68,69,80,92,93,75,76,87,99,100,76,77,88,100,101,77,78,89,101,102,78,79,90,102,103,79,80,91,103,104,80,81,92,104,105,88,89,100,112,113,89,90,101,113,114,90,91,102,114,115,91,92,103,115,116,92,93,104,116,117,28,29,41,52,53,29,30,42,53,54,30,31,43,54,55,31,32,44,55,56,32,33,45,56,57,40,41,53,64,65,41,42,54,65,66,42,43,55,66,67,43,44,56,67,68,44,45,57,68,69,45,46,58,69,70,52,53,65,76,77,53,54,66,77,78,54,55,67,78,79,55,56,68,79,80,56,57,69,80,81,57,58,70,81,82,64,65,77,88,89,65,66,78,89,90,66,67,79,90,91,67,68,80,91,92,68,69,81,92,93,69,70,82,93,94,76,77,89,100,101,77,78,90,101,102,78,79,91,102,103,79,80,92,103,104,80,81,93,104,105,81,82,94,105,106,88,89,101,112,113,89,90,102,113,114,90,91,103,114,115,91,92,104,115,116,92,93,105,116,117,39,41,51,52,53,40,42,52,53,54,41,43,53,54,55,42,44,54,55,56,43,45,55,56,57,44,46,56,57,58,51,53,63,64,65,52,54,64,65,66,53,55,65,66,67,54,56,66,67,68,55,57,67,68,69,56,58,68,69,70,63,65,75,76,77,64,66,76,77,78,65,67,77,78,79,66,68,78,79,80,67,69,79,80,81,68,70,80,81,82,75,77,87,88,89,76,78,88,89,90,77,79,89,90,91,78,80,90,91,92,79,81,91,92,93,80,82,92,93,94,87,89,99,100,101,88,90,100,101,102,89,91,101,102,103,90,92,102,103,104,91,93,103,104,105,92,94,104,105,106,100,102,112,113,114,101,103,113,114,115,102,104,114,115,116,103,105,115,116,117
};
for(int di=0;di<680; di+=5) 
{if(ei==640){z[z6]=0, z[z7]=0, z[z8]=0, z[z9]=0,z[z10]=0;z[z11]=0, z[z12]=0, z[z13]=0, z[z14]=0,z[z15]=0;continue;}
 
y++;int dd1=di,dd2=di+1,dd3=di+2,dd4=di+3,dd5=di+4;
int d1=d[dd1],d2=d[dd2],d3=d[dd3],d4=d[dd4],d5=d[dd5];
 
z11=d1-1,z12=d2-1,z13=d3-1,z14=d4-1,z15=d5-1;
if(z[z11]>0 || z[z12]>0 ||z[z13]>0 ||z[z14]>0 ||z[z15]>0)continue;
 else {z[z11]=3, z[z12]=3, z[z13]=3, z[z14]=3,z[z15]=3;}
 system ("pause"); cout<<"d"<<di<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl
<<"|"<<" "<<z[27]<<z[28]<<z[29]<<z[30]<<z[31]<<z[32]<<" "<<"|"<<endl
<<"|"<<z[38]<<z[39]<<z[40]<<z[41]<<z[42]<<z[43]<<z[44]<<z[45]<<"|"<<endl
<<"|"<<z[50]<<z[51]<<z[52]<<z[53]<<z[54]<<z[55]<<z[56]<<z[57]<<"|"<<endl
<<"|"<<z[62]<<z[63]<<z[64]<<z[65]<<z[66]<<z[67]<<z[68]<<z[69]<<"|"<<endl
<<"|"<<z[74]<<z[75]<<z[76]<<z[77]<<z[78]<<z[79]<<z[80]<<z[81]<<"|"<<endl
<<"|"<<z[86]<<z[87]<<z[88]<<z[89]<<z[90]<<z[91]<<z[92]<<z[93]<<"|"<<endl
<<"|"<<z[98]<<z[99]<<z[100]<<z[101]<<z[102]<<z[103]<<z[104]<<z[105]<<"|"<<endl
<<"|"<<" "<<z[111]<<z[112]<<z[113]<<z[114]<<z[115]<<z[116]<<" "<<"|"<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl;
 
 
 int e[]={
28,29,30,40,52,29,30,31,41,53,30,31,32,42,54,31,32,33,43,55,39,40,41,51,63,40,41,42,52,64,41,42,43,53,65,42,43,44,54,66,43,44,45,55,67,44,45,46,56,68,51,52,53,63,75,52,53,54,64,76,53,54,55,65,77,54,55,56,66,78,55,56,57,67,79,56,57,58,68,80,63,64,65,75,87,64,65,66,76,88,65,66,67,77,89,66,67,68,78,90,67,68,69,79,91,68,69,70,80,92,75,76,77,87,99,76,77,78,88,100,77,78,79,89,101,78,79,80,90,102,79,80,81,91,103,80,81,82,92,104,88,89,90,100,112,89,90,91,101,113,90,91,92,102,114,91,92,93,103,115,28,29,30,42,54,29,30,31,43,55,30,31,32,44,56,31,32,33,45,57,39,40,41,53,65,40,41,42,54,66,41,42,43,55,67,42,43,44,56,68,43,44,45,57,69,44,45,46,58,70,51,52,53,65,77,52,53,54,66,78,53,54,55,67,79,54,55,56,68,80,55,56,57,69,81,56,57,58,70,82,63,64,65,77,89,64,65,66,78,90,65,66,67,79,91,66,67,68,80,92,67,68,69,81,93,68,69,70,82,94,75,76,77,89,101,76,77,78,90,102,77,78,79,91,103,78,79,80,92,104,79,80,81,93,105,80,81,82,94,106,88,89,90,102,114,89,90,91,103,115,90,91,92,104,116,91,92,93,105,117,30,42,52,53,54,31,43,53,54,55,32,44,54,55,56,33,45,55,56,57,41,53,63,64,65,42,54,64,65,66,43,55,65,66,67,44,56,66,67,68,45,57,67,68,69,46,58,68,69,70,53,65,75,76,77,54,66,76,77,78,55,67,77,78,79,56,68,78,79,80,57,69,79,80,81,58,70,80,81,82,65,77,87,88,89,66,78,88,89,90,67,79,89,90,91,68,80,90,91,92,69,81,91,92,93,70,82,92,93,94,77,89,99,100,101,78,90,100,101,102,79,91,101,102,103,80,92,102,103,104,81,93,103,104,105,82,94,104,105,106,90,102,112,113,114,91,103,113,114,115,92,104,114,115,116,93,105,115,116,117,28,40,52,53,54,29,41,53,54,55,30,42,54,55,56,31,43,55,56,57,39,51,63,64,65,40,52,64,65,66,41,53,65,66,67,42,54,66,67,68,43,55,67,68,69,44,56,68,69,70,51,63,75,76,77,52,64,76,77,78,53,65,77,78,79,54,66,78,79,80,55,67,79,80,81,56,68,80,81,82,63,75,87,88,89,64,76,88,89,90,65,77,89,90,91,66,78,90,91,92,67,79,91,92,93,68,80,92,93,94,75,87,99,100,101,76,88,100,101,102,77,89,101,102,103,78,90,102,103,104,79,91,103,104,105,80,92,104,105,106,88,100,112,113,114,89,101,113,114,115,90,102,114,115,116,91,103,115,116,117
};
for(int ei=0;ei<640; ei+=5)
{if(fi==580){z[z11]=0, z[z12]=0, z[z13]=0, z[z14]=0,z[z15]=0;z[z16]=0, z[z17]=0, z[z18]=0, z[z19]=0,z[z20]=0;continue;}
y++;int ee1=ei,ee2=ei+1,ee3=ei+2,ee4=ei+3,ee5=ei+4;
int e1=e[ee1],e2=e[ee2],e3=e[ee3],e4=e[ee4],e5=e[ee5];
 
z16=e1-1,z17=e2-1,z18=e3-1,z19=e4-1,z20=e5-1;
 
if(z[z16]>0 || z[z17]>0 ||z[z18]>0 ||z[z19]>0 ||z[z20]>0)continue;
 else {z[z16]=4, z[z17]=4, z[z18]=4, z[z19]=4,z[z20]=4;}
 system ("pause"); cout<<"e"<<ei<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl
<<"|"<<" "<<z[27]<<z[28]<<z[29]<<z[30]<<z[31]<<z[32]<<" "<<"|"<<endl
<<"|"<<z[38]<<z[39]<<z[40]<<z[41]<<z[42]<<z[43]<<z[44]<<z[45]<<"|"<<endl
<<"|"<<z[50]<<z[51]<<z[52]<<z[53]<<z[54]<<z[55]<<z[56]<<z[57]<<"|"<<endl
<<"|"<<z[62]<<z[63]<<z[64]<<z[65]<<z[66]<<z[67]<<z[68]<<z[69]<<"|"<<endl
<<"|"<<z[74]<<z[75]<<z[76]<<z[77]<<z[78]<<z[79]<<z[80]<<z[81]<<"|"<<endl
<<"|"<<z[86]<<z[87]<<z[88]<<z[89]<<z[90]<<z[91]<<z[92]<<z[93]<<"|"<<endl
<<"|"<<z[98]<<z[99]<<z[100]<<z[101]<<z[102]<<z[103]<<z[104]<<z[105]<<"|"<<endl
<<"|"<<" "<<z[111]<<z[112]<<z[113]<<z[114]<<z[115]<<z[116]<<" "<<"|"<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl;
 
 
int f[]={
28,29,41,42,54,29,30,42,43,55,30,31,43,44,56,32,33,45,46,58,39,40,52,53,65,40,41,53,54,66,41,42,54,55,67,42,43,55,56,68,43,44,56,57,69,51,52,64,65,77,52,53,65,66,78,53,54,66,67,79,54,55,67,68,80,55,56,68,69,81,56,57,69,70,82,63,64,76,77,89,64,65,77,78,90,65,66,78,79,91,66,67,79,80,92,67,68,80,81,93,68,69,81,82,94,76,77,89,90,102,77,78,90,91,103,78,79,91,92,104,79,80,92,93,105,80,81,93,94,106,89,90,102,103,115,90,91,103,104,116,91,92,104,105,117,28,29,39,40,51,30,31,41,42,53,31,32,42,43,54,32,33,43,44,55,41,42,52,53,64,42,43,53,54,65,43,44,54,55,66,44,45,55,56,67,45,46,56,57,68,52,53,63,64,75,53,54,64,65,76,54,55,65,66,77,55,56,66,67,78,56,57,67,68,79,57,58,68,69,80,64,65,75,76,87,65,66,76,77,88,66,67,77,78,89,67,68,78,79,90,68,69,79,80,91,69,70,80,81,92,76,77,87,88,99,77,78,88,89,100,78,79,89,90,101,79,80,90,91,102,80,81,91,92,103,89,90,100,101,112,90,91,101,102,113,91,92,102,103,114,31,42,43,53,54,32,43,44,54,55,33,44,45,55,56,42,53,54,64,65,43,54,55,65,66,44,55,56,66,67,45,56,57,67,68,46,57,58,68,69,53,64,65,75,76,54,65,66,76,77,55,66,67,77,78,56,67,68,78,79,57,68,69,79,80,58,69,70,80,81,65,76,77,87,88,66,77,78,88,89,67,78,79,89,90,68,79,80,90,91,69,80,81,91,92,70,81,82,92,93,77,88,89,99,100,78,89,90,100,101,79,90,91,101,102,80,91,92,102,103,81,92,93,103,104,90,101,102,112,113,91,102,103,113,114,92,103,104,114,115,94,105,106,116,117,28,40,41,53,54,29,41,42,54,55,30,42,43,55,56,39,51,52,64,65,40,52,53,65,66,41,53,54,66,67,42,54,55,67,68,43,55,56,68,69,51,63,64,76,77,52,64,65,77,78,53,65,66,78,79,54,66,67,79,80,55,67,68,80,81,56,68,69,81,82,63,75,76,88,89,64,76,77,89,90,65,77,78,90,91,66,78,79,91,92,67,79,80,92,93,68,80,81,93,94,76,88,89,101,102,77,89,90,102,103,78,90,91,103,104,79,91,92,104,105,80,92,93,105,106,87,99,100,112,113,89,101,102,114,115,90,102,103,115,116,91,103,104,116,117
};
for(int fi=0;fi<580; fi+=5)
{if(gi==640){z[z16]=0, z[z17]=0, z[z18]=0, z[z19]=0,z[z20]=0;z[z21]=0, z[z22]=0, z[z23]=0, z[z24]=0,z[z25]=0;continue;}
y++;int ff1=fi,ff2=fi+1,ff3=fi+2,ff4=fi+3,ff5=fi+4;
int f1=f[ff1],f2=f[ff2],f3=f[ff3],f4=f[ff4],f5=f[ff5];
 
z21=f1-1,z22=f2-1,z23=f3-1,z24=f4-1,z25=f5-1;
 
if(z[z21]>0 || z[z22]>0 ||z[z23]>0 ||z[z24]>0 ||z[z25]>0)continue;
 else {z[z21]=5, z[z22]=5, z[z23]=5, z[z24]=5,z[z25]=5;}
 system ("pause"); cout<<"f"<<fi<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl
<<"|"<<" "<<z[27]<<z[28]<<z[29]<<z[30]<<z[31]<<z[32]<<" "<<"|"<<endl
<<"|"<<z[38]<<z[39]<<z[40]<<z[41]<<z[42]<<z[43]<<z[44]<<z[45]<<"|"<<endl
<<"|"<<z[50]<<z[51]<<z[52]<<z[53]<<z[54]<<z[55]<<z[56]<<z[57]<<"|"<<endl
<<"|"<<z[62]<<z[63]<<z[64]<<z[65]<<z[66]<<z[67]<<z[68]<<z[69]<<"|"<<endl
<<"|"<<z[74]<<z[75]<<z[76]<<z[77]<<z[78]<<z[79]<<z[80]<<z[81]<<"|"<<endl
<<"|"<<z[86]<<z[87]<<z[88]<<z[89]<<z[90]<<z[91]<<z[92]<<z[93]<<"|"<<endl
<<"|"<<z[98]<<z[99]<<z[100]<<z[101]<<z[102]<<z[103]<<z[104]<<z[105]<<"|"<<endl
<<"|"<<" "<<z[111]<<z[112]<<z[113]<<z[114]<<z[115]<<z[116]<<" "<<"|"<<endl
<<"+"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"-"<<"+"<<endl;
 
 
 int g[]={
29,30,41,52,53,30,31,42,53,54,31,32,43,54,55,32,33,44,55,56,40,41,52,63,64,41,42,53,64,65,42,43,54,65,66,43,44,55,66,67,44,45,56,67,68,45,46,57,68,69,52,53,64,75,76,53,54,65,76,77,54,55,66,77,78,55,56,67,78,79,56,57,68,79,80,57,58,69,80,81,64,65,76,87,88,65,66,77,88,89,66,67,78,89,90,67,68,79,90,91,68,69,80,91,92,69,70,81,92,93,76,77,88,99,100,77,78,89,100,101,78,79,90,101,102,79,80,91,102,103,80,81,92,103,104,81,82,93,104,105,89,90,101,112,113,90,91,102,113,114,91,92,103,114,115,92,93,104,115,116,28,29,41,53,54,29,30,42,54,55,30,31,43,55,56,31,32,44,56,57,39,40,52,64,65,40,41,53,65,66,41,42,54,66,67,42,43,55,67,68,43,44,56,68,69,44,45,57,69,70,51,52,64,76,77,52,53,65,77,78,53,54,66,78,79,54,55,67,79,80,55,56,68,80,81,56,57,69,81,82,63,64,76,88,89,64,65,77,89,90,65,66,78,90,91,66,67,79,91,92,67,68,80,92,93,68,69,81,93,94,75,76,88,100,101,76,77,89,101,102,77,78,90,102,103,78,79,91,103,104,79,80,92,104,105,80,81,93,105,106,88,89,101,113,114,89,90,102,114,115,90,91,103,115,116,91,92,104,116,117,30,40,41,42,52,31,41,42,43,53,32,42,43,44,54,33,43,44,45,55,41,51,52,53,63,42,52,53,54,64,43,53,54,55,65,44,54,55,56,66,45,55,56,57,67,46,56,57,58,68,53,63,64,65,75,54,64,65,66,76,55,65,66,67,77,56,66,67,68,78,57,67,68,69,79,58,68,69,70,80,65,75,76,77,87,66,76,77,78,88,67,77,78,79,89,68,78,79,80,90,69,79,80,81,91,70,80,81,82,92,77,87,88,89,99,78,88,89,90,100,79,89,90,91,101,80,90,91,92,102,81,91,92,93,103,82,92,