Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure Read4Nums(var n1,n2,n3,n4:longint);
- begin
- read(n1,n2,n3,n4); //read 4 nums
- end;
- procedure FindCountMethods(i1,i2,i3:longint;a,b,c,n:longint);
- var i,j,k,mtd:longint;
- begin
- mtd:=0;
- for i := 0 to i1 do //repeat cycle eq weight of prod, that we can buy from 1st box
- for j := 0 to i2 do //repeat cycle eq weight of prod, that we can buy from 2nd box
- for k := 0 to i3 do //repeat cycle eq weight of prod, that we can buy from 3d box
- if i * a + j * b + k * c = n then //if weight of all product we can buy matches weight of product we need to but then
- mtd := mtd + 1; //add to number of method 1
- writeln(mtd); //write method
- end;
- procedure WriteMtds(i1,i2,i3:longint;a,b,c,n:longint);
- var i,j,k:longint;
- begin
- for i := 0 to i1 do //repeat cycle eq weight of prod, that we can buy from 1st box
- for j := 0 to i2 do //repeat cycle eq weight of prod, that we can buy from 2nd box
- for k := 0 to i3 do //repeat cycle eq weight of prod, that we can buy from 3d box
- if i * a + j * b + k * c = n then //if weight of all product we can buy matches weight of product we need to but then
- writeln(i, ' ', j, ' ', k); //write weight of product that we can bout from 1st box, 2nd box, 3d box with spaces
- end;
- var
- n, a, b, c, mtd, i1, i2, i3, i, j, k: longint;
- begin
- read(a, b, c, n); //read read wheight of every type of the product and count of product, need to buy
- mtd := 0; //firstly num of methods eq 0
- i1 := n div a; //weight of product from 1st box
- i2 := n div b; //weight of product from 2nd box
- i3 := n div c; //weight of product from 3d box
- FindCountMethods(i1,i2,i3,a,b,c,n); //Find and Write count of methods that product can be distributed
- WriteMtds(i1,i2,i3,a,b,c,n); //write this methods
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement