一道虽然简单 但很多人都有错的算法 有关问题

一道虽然简单 但很多人都有错的算法 问题
2、有个321米长的钢材料,把截取成两种规格的短料,规格口,易的长度分别为17米和27米,问a,b个分成多少段后,残余的材料最少啊?


这题的应该怎样判断在什么样的情况     为最少啊?
入口在哪啊?

------解决方案--------------------
Private Sub Command3_Click()
'321,17,27

Dim i As Integer
Dim j As Integer
Const intLen As Integer = 321
Const aPer As Integer = 17
Const bPer As Integer = 27
Dim iMin As Integer
Dim iLeft As Integer

iMin = 99
For i = 0 To Int(intLen / aPer)
iLeft = (intLen - aPer * i) Mod bPer
If iLeft < iMin Then
iMin = iLeft
j = i
End If
Next
MsgBox j & ": " & iMin
End Sub