Home > Software engineering >  For help! Brute force!
For help! Brute force!

Time:05-07



Using vb, command buttons source!

CodePudding user response:

Written, without the result of running time is longer, according to the circumstances of computer may be a few hours to a few days, the code is as follows:
 
Option Explicit

Private Sub cmdStartCombine_Click ()
TextI=""
TextJ=""
TextK=""
TextResult=""

Dim As Long a
A=TextA

Dim As Long b
B=TextB

Dim As Long c
C=TextC

Dim d As Long
D=TextD

Dim As Long I
For I=0 To 10000
DoEvents

Dim j As Long
For j=0 To 10000
Dim k As Long
For k=0 To 10000
Dim temp As Long
Temp=d * (a * I j + + b * c * k)

If 93 * I & gt; Temp And 930 * j & gt; Temp And 9000 * k & gt; Temp Then
TextI=I
TextJ=j
TextK=k
TextResult="combination is complete."
The Exit Sub
End the If
Next
Next
Next

TextResult="without this combination!"

End Sub

Download address:
Link: https://pan.baidu.com/s/1tivqdNAETJw0_bGJQgYZSw
Numbers: 2 f6p

Run the example:

CodePudding user response:

Range of values of the a, b, c were not qualified,
It may appear "tens of millions" or even "several hundred" meet the requirements of combination;
, of course, also can appear "no result",


As for the upstairs said "no results running time is longer,"
That's algorithm logic problem,
In fact when "no result", a reasonable algorithm can be "complete" immediately,
(take "almost zero")

  • Related