program Bai_13_FoToDo_Doi_Tien;
uses crt;
var n1,n2,n3,x,y,z :longint; ST :qword;
begin
repeat
write('Nhap so tien can doi: ');readln(ST)
until (ST>0)and (ST mod 2=0);
n1:=ST div 1000; // }
n2:=ST div 2000; // }So to tien toi da cua moi loai.
n3:=ST div 5000; // }
For x:=0 to n1 do
For y:=0 to n2 do
For z:=0 to n3 do
if (1000*x+2000*y+5000*z=ST)then
writeln(x:4,y:4,z:4);
readln;
end.
Chúc bạn thành công!!