27 lines
939 B
Plaintext
27 lines
939 B
Plaintext
func Min(A, B);
|
|
real A, B;
|
|
return fix(if A < B then A else B);
|
|
|
|
int Panacea, Ichor, Gold, Panacea_, Ichor_, Gold_, Val, Max;
|
|
real Weight, Volume;
|
|
[Max:= 0;
|
|
for Panacea:= 0 to Min(25.0/0.3, 0.25/0.025) do
|
|
[for Ichor:= 0 to Min(25.0/0.2, 0.25/0.015) do
|
|
[for Gold:= 0 to Min(25.0/2.0, 0.25/0.002) do
|
|
[Val:= Panacea*3000 + Ichor*1800 + Gold*2500;
|
|
Weight:= float(Panacea)*0.3 + float(Ichor)*0.2 + float(Gold)*2.0;
|
|
Volume:= float(Panacea)*0.025 + float(Ichor)*0.015 + float(Gold)*0.002;
|
|
if Val>Max and Weight<=25.0 and Volume<= 0.25 then
|
|
[Max:= Val;
|
|
Panacea_:= Panacea; Ichor_:= Ichor; Gold_:= Gold;
|
|
];
|
|
];
|
|
];
|
|
];
|
|
Text(0, "The traveler carries ");
|
|
IntOut(0, Panacea_); Text(0, " vials of panacea, ");
|
|
IntOut(0, Ichor_); Text(0, " ampules of ichor, and ");
|
|
IntOut(0, Gold_); Text(0, " bars of gold"); CrLf(0);
|
|
Text(0, "for a maximum value of "); IntOut(0, Max); CrLf(0);
|
|
]
|