|
本帖最后由 香川群子 于 2014-4-25 22:49 编辑
abc3d 发表于 2014-4-25 21:21
看到附件了,正是要的,能不能再加一个条件,求版主改为4列6行,就是1234等式之间的行数
那这样缩减行数以后,计算结果数大大减少……剩下 17091组
程序修改:
① 行列大小自动按照A1所在区域的实际行、列数。
② 计算结果存入数组,按5000次单位输出到工作表- Sub kagawa() '2014/04/25
- Dim i11&, j11&, i12&, j12&, i13&, j13&
- Dim i21&, j21&, i22&, j22&, i23&, j23&
- Dim t11&, t21&, t12&, t22&
- Dim ar, m&, n&, r&, s$, cnt&, tms#
- tms = Timer
-
- ar = [a1].CurrentRegion
- m = UBound(ar): n = UBound(ar, 2)
- ReDim arr&(1 To m, 1 To n)
- ReDim brr&(1 To m, 1 To n)
- For i11 = 1 To m
- For j11 = 1 To n
- arr(i11, j11) = Cells(i11, j11)
- Next
- Next
-
- ReDim crr(1 To 10000, 1 To 15)
- [h11] = 0: r = 0
- [a11].CurrentRegion.Offset(2) = ""
- For i11 = 1 To m - 2
- For j11 = 1 To n
- brr(i11, j11) = 1
- For i12 = 1 To m - 1
- For j12 = IIf(i11 = i12, j11 + 1, 1) To n
- 'If brr(i12, j12) Then Stop
- brr(i12, j12) = 1
- For i13 = i11 + 1 To m - 1
- For j13 = IIf(i12 = i13, j12 + 1, 1) To n
- 'If brr(i13, j13) Then Stop
- brr(i13, j13) = 1
-
- For i21 = i11 To m - 2
- For j21 = IIf(i11 = i21, j11 + 1, 1) To n
- If brr(i21, j21) Then
- ' Stop 'pass
- Else
- brr(i21, j21) = 1
- For i22 = 1 To m - 1
- For j22 = IIf(i21 = i22, j21 + 1, 1) To n
- If brr(i22, j22) Then
- ' Stop 'pass
- Else
- brr(i22, j22) = 1
- For i23 = i21 + 1 To m - 1
- For j23 = IIf(i22 = i23, j22 + 1, 1) To n
- If brr(i23, j23) Then
- ' Stop 'pass
- Else
- cnt = cnt + 1
- t11 = (arr(i11, j11) + arr(i12, j12) + arr(i13, j13)) Mod 10
- t21 = (arr(i21, j21) + arr(i22, j22) + arr(i23, j23)) Mod 10
- If t11 = t21 Then
- t12 = (arr(i11 + 1, j11) + arr(i12 + 1, j12) + arr(i13 + 1, j13)) Mod 10
- t22 = (arr(i21 + 1, j21) + arr(i22 + 1, j22) + arr(i23 + 1, j23)) Mod 10
- If t12 = t22 Then
- ' Stop
- r = r + 1
- crr(r, 1) = Cells(i11, j11).Address(0, 0)
- crr(r, 2) = Cells(i12, j12).Address(0, 0)
- crr(r, 3) = Cells(i13, j13).Address(0, 0)
- crr(r, 5) = Cells(i21, j21).Address(0, 0)
- crr(r, 6) = Cells(i22, j22).Address(0, 0)
- crr(r, 7) = Cells(i23, j23).Address(0, 0)
- crr(r, 9) = Cells(i11 + 1, j11).Address(0, 0)
- crr(r, 10) = Cells(i12 + 1, j12).Address(0, 0)
- crr(r, 11) = Cells(i13 + 1, j13).Address(0, 0)
- crr(r, 13) = Cells(i21 + 1, j21).Address(0, 0)
- crr(r, 14) = Cells(i22 + 1, j22).Address(0, 0)
- crr(r, 15) = Cells(i23 + 1, j23).Address(0, 0)
-
- r = r + 1
- crr(r, 1) = arr(i11, j11)
- crr(r, 2) = arr(i12, j12)
- crr(r, 3) = arr(i13, j13)
- crr(r, 4) = t11
- crr(r, 5) = arr(i21, j21)
- crr(r, 6) = arr(i22, j22)
- crr(r, 7) = arr(i23, j23)
- crr(r, 9) = arr(i11 + 1, j11)
- crr(r, 10) = arr(i12 + 1, j12)
- crr(r, 11) = arr(i13 + 1, j13)
- crr(r, 12) = t22
- crr(r, 13) = arr(i21 + 1, j21)
- crr(r, 14) = arr(i22 + 1, j22)
- crr(r, 15) = arr(i23 + 1, j23)
-
- If r = 10000 Then
- Cells(Cells.Rows.Count, 1).End(3).Offset(1).Resize(10000, 15) = crr
- [h11] = [h11] + 5000: r = 0
- End If
-
- End If
- End If
-
- End If
- Next
- Next
- brr(i22, j22) = 0
- End If
- Next
- Next
- brr(i21, j21) = 0
- End If
- Next
- Next
-
- Application.StatusBar = i11 & "," & j11 & " " & i12 & "," & j12 & " " & i13 & "," & j13 & "| " & [h11] + r / 2
- brr(i13, j13) = 0
- Next
- Next
- brr(i12, j12) = 0
- Next
- Next
- brr(i11, j11) = 0
- Next
- Next
- [h11] = [h11] + r / 2
- Application.StatusBar = i11 & "," & j11 & " " & i12 & "," & j12 & " " & i13 & "," & j13 & "| " & [h11]
- If r Then Cells(Cells.Rows.Count, 1).End(3).Offset(1).Resize(r, 15) = crr
- MsgBox Format(Timer - tms, "0.000s ") & [h11] & " / " & cnt
- End Sub
复制代码 附件为2003版 和 2007版
二组尾数相同2.rar
(32.14 KB, 下载次数: 21)
|
|