Public Class Form1
    Dim X1, X2, X3, F As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        F = 300
        For X1 = 0 To 100
            For X2 = 0 To 100
                For X3 = 0 To 100
                    If 10 * X1 + 3 * X2 + 8 * X3 = 500 And 3 * X1 + 6 * X2 + 4 * X3 = 300 Then
                        If X1 + X2 + X3 < F Then
                            F = X1 + X2 + X3
                            Label1.Text = X1
                            Label2.Text = X2
                            Label3.Text = X3
                            Label4.Text = F
                        End If
                    End If
                Next X3
            Next X2
        Next X1
    End Sub
End Class
