Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- eps: double = 1e-9;
- type
- bottle = record
- i, c1, c2: longint;
- v: double;
- end;
- cup = record
- i: longint;
- b: array[1..50] of double;
- v: double;
- end;
- var
- k, i, j, n, m: longint;
- w, w0: double;
- b: array[1..50] of bottle;
- c: array[1..50] of cup;
- f: boolean;
- begin
- read(n, w, m);
- if 2 * n < m then begin
- writeln('NO');
- halt;
- end;
- w0 := n * w / m;
- for i := 1 to n do begin
- b[i].i := i;
- b[i].c1 := 0;
- b[i].c2 := 0;
- b[i].v := w;
- end;
- for i := 1 to m do begin
- c[i].i := i;
- c[i].v := 0;
- for j := 1 to n do c[i].b[j] := 0;
- end;
- for k := 1 to 2 * n do begin
- i := (k + 1) div 2;
- if abs(b[i].v) < eps then continue;
- for j := 1 to m do begin
- if abs(c[j].v - w0) < eps then continue;
- if (b[i].c1 = j) or (b[i].c2 = j) then continue;
- if (b[i].c1 <> 0) and (b[i].c2 <> 0) then continue;
- if b[i].c1 = 0 then
- b[i].c1 := j
- else
- b[i].c2 := j;
- if b[i].v > w0 - c[j].v + eps then begin
- b[i].v := b[i].v - (w0 - c[j].v);
- c[j].b[b[i].i] := w0 - c[j].v;
- c[j].v := w0;
- end else begin
- c[j].v := c[j].v + b[i].v;
- c[j].b[b[i].i] := b[i].v;
- b[i].v := 0;
- end;
- break;
- end;
- end;
- for i := 1 to m do begin
- if abs(c[i].v - w0) > eps then begin
- writeln('NO');
- halt;
- end;
- end;
- writeln('YES');
- for i := 1 to m do begin
- f := true;
- for j := 1 to n do begin
- if c[i].b[j] > eps then begin
- if f then f := false else write(' ');
- write(j, ' ', c[i].b[j]:0:12);
- end;
- end;
- writeln;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment