Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
76
Task/Cut-a-rectangle/EasyLang/cut-a-rectangle.easy
Normal file
76
Task/Cut-a-rectangle/EasyLang/cut-a-rectangle.easy
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
global grid[] blen w h cnt .
|
||||
dir[][] = [ [ 0 -1 ] [ -1 0 ] [ 0 1 ] [ 1 0 ] ]
|
||||
#
|
||||
proc walk y x . .
|
||||
if y = 0 or y = h or x = 0 or x = w
|
||||
cnt += 2
|
||||
return
|
||||
.
|
||||
t = y * (w + 1) + x
|
||||
grid[t] += 1
|
||||
grid[blen - t] += 1
|
||||
for i to 4
|
||||
dx = dir[i][1]
|
||||
dy = dir[i][2]
|
||||
d = dx + dy * (w + 1)
|
||||
if grid[t + d] = 0
|
||||
walk y + dy x + dx
|
||||
.
|
||||
.
|
||||
grid[t] -= 1
|
||||
grid[blen - t] -= 1
|
||||
.
|
||||
proc solve hh ww recur . .
|
||||
w = ww
|
||||
h = hh
|
||||
if h mod 2 = 1
|
||||
swap h w
|
||||
.
|
||||
if h mod 2 = 1
|
||||
cnt = 0
|
||||
return
|
||||
.
|
||||
if w = 1
|
||||
cnt = 1
|
||||
return
|
||||
.
|
||||
if w = 2
|
||||
cnt = h
|
||||
return
|
||||
.
|
||||
if h = 2
|
||||
cnt = w
|
||||
return
|
||||
.
|
||||
cy = h div 2 ; cx = w div 2
|
||||
blen = (h + 1) * (w + 1)
|
||||
grid[] = [ ]
|
||||
len grid[] blen
|
||||
blen -= 1
|
||||
if recur = 1
|
||||
cnt = 0
|
||||
.
|
||||
for x = cx + 1 to w - 1
|
||||
t = cy * (w + 1) + x
|
||||
grid[t] = 1
|
||||
grid[blen - t] = 1
|
||||
walk cy - 1 x
|
||||
.
|
||||
cnt += 1
|
||||
if h = w
|
||||
cnt *= 2
|
||||
elif w mod 2 = 0 and recur = 1
|
||||
solve w h 0
|
||||
.
|
||||
.
|
||||
proc main . .
|
||||
for y = 1 to 8
|
||||
for x = 1 to y
|
||||
if x mod 2 = 0 or y mod 2 = 0
|
||||
solve y x 1
|
||||
print y & " x " & x & ": " & cnt
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue