Module Module1 Sub Main() FileOpen(1, "DATA4.txt", OpenMode.Input) FileOpen(2, "OUT4.txt", OpenMode.Output) For i As Integer = 0 To 4 Dim total As Integer = CInt(LineInput(1)) Dim a As Integer = CInt(LineInput(1)) Dim values(a - 1) As Integer Dim max(a - 1) As Integer Dim min As Integer = 99999 For b As Integer = 0 To a - 1 values(b) = CInt(LineInput(1)) max(b) = total / values(b) Next If a = 4 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 Dim hcount As Integer = x1 + x2 + x3 + x4 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next End If If a = 3 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 Dim hcount As Integer = x1 + x2 + x3 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next End If If a = 2 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) Dim haha As Integer = values(0) * x1 + values(1) * x2 Dim hcount As Integer = x1 + x2 If haha = total Then If hcount < min Then min = hcount End If End If Next Next End If If a = 5 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next End If If a = 6 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) For x6 As Integer = 0 To max(5) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 + values(5) * x6 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 + x6 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next Next End If If a = 7 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) For x6 As Integer = 0 To max(5) For x7 As Integer = 0 To max(6) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 + values(5) * x6 + values(6) * x7 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 + x6 + x7 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next Next Next End If If a = 8 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) For x6 As Integer = 0 To max(5) For x7 As Integer = 0 To max(6) For x8 As Integer = 0 To max(7) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 + values(5) * x6 + values(6) * x7 + values(7) * x8 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next Next Next Next End If If a = 9 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) For x6 As Integer = 0 To max(5) For x7 As Integer = 0 To max(6) For x8 As Integer = 0 To max(7) For x9 As Integer = 0 To max(8) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 + values(5) * x6 + values(6) * x7 + values(7) * x8 + values(8) * x9 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next Next Next Next Next End If If a = 10 Then For x1 As Integer = 0 To max(0) For x2 As Integer = 0 To max(1) For x3 As Integer = 0 To max(2) For x4 As Integer = 0 To max(3) For x5 As Integer = 0 To max(4) For x6 As Integer = 0 To max(5) For x7 As Integer = 0 To max(6) For x8 As Integer = 0 To max(7) For x9 As Integer = 0 To max(8) For x10 As Integer = 0 To max(9) Dim haha As Integer = values(0) * x1 + values(1) * x2 + values(2) * x3 + values(3) * x4 + values(4) * x5 + values(5) * x6 + values(6) * x7 + values(7) * x8 + values(8) * x9 + values(9) * x10 Dim hcount As Integer = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 If haha = total Then If hcount < min Then min = hcount End If End If Next Next Next Next Next Next Next Next Next Next End If Dim out As String = CStr(min) PrintLine(2, out) Next End Sub End Module