

problem(A,B,C,Profit,Cout) :- 
    fd_domain([A,B,C],1,10000), 
    fd_domain(Profit,0,10000),
    Cout #=< 2000, Profit #= 30*A + 40*B + 70*C,
    cout(A,B,C,Cout),
    fd_labeling([A,B,C,Cout,Profit]).

prob(A,B,C,Profit,Cout) :-
    fd_maximize(problem(A,B,C,Profit,Cout),Profit).
    
coutA(1,100).
coutA(2,170).
coutA(3,220).
coutA(N,C) :- N #> 3, C #= 220 + (N-3)*35.

coutB(1,200).
coutB(2,340).
coutB(3,405).
coutB(N,C) :- N #> 3, C #= 405 + (N-3)*50.

coutC(1,450).
coutC(2,750).
coutC(3,950).
coutC(N,C) :- N #> 3, C #= 750 + (N-3)*100.


cout(A,B,C,Cout) :-
    coutA(A,CA), coutB(B,CB), coutC(C,CC), Cout #= CA + CB + CC.
