½Ð±Ð³B²z16Ó¥¿¾ã¼Æªº¤£©w¤èµ{°ÝÃD
- ©«¤l
- 1
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 2
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office2010
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2013-1-30
- ³Ì«áµn¿ý
- 2013-1-30
|
½Ð±Ð³B²z16Ó¥¿¾ã¼Æªº¤£©w¤èµ{°ÝÃD
½Ð±Ð¦U¦ì¤j¤j:
Y¦³16ÓÅܶq a,b,c,...,p
¨CÓÅܶq³£¬O1¨ì16ªº¥¿¾ã¼Æ¡A¥B¦U¦Û©¼¦¹³£¤£¦P¡A
³o¨ÇÅܶq¨ã¦³¥H¤U³o¨Ç¤èµ{Ãö«Y:
a+b+c+d+e+f+g=49+s
2*b+c+2*d+e+2*f+g=87-s
¨ä¤¤, s=0,1,...,21
h+i+j=d+e+f
k+l+m=b+g+f
n+o+p=b+c+d
§Ú°Ñ¦Òºô¸ô¤@¨Ç¸ê®Æ¡A¥Hs=0,s=1...,s=21¤À¶}³B²z
¥Î°j°éªº¤è¦¡(For Next)¥ý§ä¥X¤Fa¨ìgªº7ÓÅܶq¡A
¦ý¬O«á¨Ó¥é·Ó¥[¤J¨ä¾l9ÓÅܶq(h,i,j,...,p)«o¤@ª½·í±¼¡A
¦³ºô¤Í»¡¦]¬°¥Î°j°é¡A³Ì«á·|¬O16^15¡A©Ò¥HµLªk³B²z¡A¦ý¥Ø«e¤]·Q¤£¨ì¨ä¥L¤è¦¡¡A
©Ò¥H·Q½Ð±Ð¦U¦ì¬O¤£¬O¦³¨ä¥L¤è¦¡¥i¥H³B²z©O?
¥H¤U¬O¶]«e7ÓÅܶqªº»yªk(s=0)
Function Unequal(ParamArray Nums() As Variant) As Integer
Dim intI1 As Integer, intI2 As Integer, l As Integer, u As Integer
l = LBound(Nums())
u = UBound(Nums())
If u - l < 1 Then
Unequal = 3
Exit Function
End If
For intI1 = l To u - 1
For intI2 = intI1 + 1 To u
If Nums(intI1) = Nums(intI2) Then
Unequal = 0
Exit Function
End If
Next
Next
Unequal = 1
End Function
Sub hexagonhive ()
For a = 1 To 16
For b = 1 To 16
For c = 1 To 16
For d = 1 To 16
For e = 1 To 16
For f = 1 To 16
g = 49 - a - b - c - d - e ¡V f
Dim ue As Integer, str As String
ue = Unequal(a, b, c, d, e, f, g)
If ue = 1 And g > 0 And g < 17 And 2 * b + c + 2 * d + e + 2 * f + g = 87 Then
t = t + 1
Cells(t, 1) = a: Cells(t, 2) = b: Cells(t, 3) = c: Cells(t, 4) = d: Cells(t, 5) = e: Cells(t, 6) = f: Cells(t, 7) = g:
End If
Next f, e, d, c, b, a
End Sub |
|
|
|
|
|
|
- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 1# kain
§A§âdim±q°j°é¤¤´£¥X¨Ó¬Ý¬Ý |
|
|
|
|
|
|
- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
§Ú§âÅܼƫ·s«Å§i¦Ó¤w
¬O¯à¶]¥X¨Óªº (¯Ó®É38¬í)
¶]¥X252ºØ²Õ¦X- Sub hexagonhive()
- Dim ue As Integer, str As String
- Dim a As Integer, b As Integer, c As Integer, d As Integer, e As Integer, f As Integer, g As Integer
- Dim t As Long
- t = 0
- Debug.Print Time
- For a = 1 To 16
- For b = 1 To 16
- For c = 1 To 16
- For d = 1 To 16
- For e = 1 To 16
- For f = 1 To 16
- g = 49 - a - b - c - d - e - f
- ue = Unequal(a, b, c, d, e, f, g)
-
- If ue = 1 And g > 0 And g < 17 And 2 * b + c + 2 * d + e + 2 * f + g = 87 Then
- t = t + 1
- Cells(t, 1) = a: Cells(t, 2) = b: Cells(t, 3) = c: Cells(t, 4) = d: Cells(t, 5) = e: Cells(t, 6) = f: Cells(t, 7) = g:
- End If
- Next f, e, d, c, b, a
- Debug.Print Time
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|