設:
吃了多少串豬肉、牛肉串為 x_count, y_count (未知)
豬肉(X)、牛肉(Y)串的單價為 x_price, y_price (已知)
付款金額(N)為pay 總共的竹籤(M)為count (已知)
==========================
根據題意解方程:
(1): x_count * x_price + y_count * y_price = pay
(2): x_count + y_count = count
(2)代入(1)得
=> y_count = ( x_price * count - pay ) / ( x_price - y_price )
==========================
方程解為正整數=店家沒算錯:輸出整數型態的 x_count, y_count
否則輸出-1 -1
hint: 絕對值