n = 100 'nado golov
c = 10000 'vsego deneg in kopeek
k1 = 1000 'tsena za bika
k2 = 500 'za korovu
k3 = 50 'za telenka
FOR i = 0 TO c \ k1
FOR j = 0 TO c \ k2
FOR k = 0 TO c \ k3
IF i + j + k = n AND i * k1 + j * k2 * k * k3 = c THEN PRINT "Bikov:"; i; " Korov:"; j; " Telyat:"; k
NEXT
NEXT
NEXT
Тестирование выполнено в программе QB64 ( Скачать )