按照比赛要求,可以设置赛程表为n行n-1列的二维表,其中第i行第j列的元素表示和第i个选手在第j天进行比赛的同学编号。
若k=1,则赛程表如下:
若k=2,则赛程表如下:
观察两个表不难发现:
①第二个表的左上角和右下角与第一个表相同;
②第二个表的左下角和右上角相同,恰好是第一个表各元素值加2。
因此可以通过第一个表来构造第二个表。同理可得,当n=2k个同学的比赛日程表,可以通过n=2k-1 个同学的比赛日程表构造得到。
请回答下列问题:
Private Sub Command1_Click()
Dim a(1 To 10000) As Integer
Dim n As Long, tmp As Long, i As Integer, j As Integer, t As Integer
a(1) = 1 : n = 1
k = Val(Text1.Text)
For t = 1 To k
n = n * 2
For i = tmp + 1 To n
For j = 1 To tmp
Next j
Next i
For i =
For j = tmp + 1 To n
a((i - 1) * 2 ^ k + j) = a((i + tmp - 1) * 2 ^ k + (j + tmp) Mod n)
Next j
Next i
For i = tmp + 1 To n
For j = tmp + 1 To n
a((i - 1) * 2 ^ k + j) = a((i - tmp - 1) * 2 ^ k + j - tmp)
Next j
Next i
Next t
For i = 1 To n
st = ""
For j = 1 To n
st = st + Str(a((i - 1) * 2 ^ k + j))
Next j
List1.AddItem st
Next i
End Sub