Private Sub Command1_Click()
Dim n%,x%,y%,z%
n = 0
For x=5 to 100
For y=5 to 50
For z=5 to 20
If x + y * 2 + z * 5 = 100 Then n=n+1
Next
Next
Next
Print n
End Sub
这样做,答案就是205。
Dim i As Long, j As Long, k As Long, n As Long
n = 0
For i = 5 To 100
For j = 5 To 50
For k = 5 To 20
If i + j * 2 + k * 5 = 100 Then n = n + 1
Next k
Next j
Next i
MsgBox n