|
|
back to boardADMINS! What is Test#6? My program always WA in Test#6. What is Test#6? program Problem; function min( x, y: integer ): integer; begin if x < y then result:=x else result:=y; end; function max(x, y: integer): integer; begin if x > y then result := x else result := y; end; type
TKan = array[0..2]of byte; var Ok: array[0..255, 0..255, 0..255 ] of Boolean; R: array[1..1000] of boolean; K, Y: TKan; Count: Integer; procedure Calc(X: TKan ); var d, i, j: byte; begin if not Ok[X[0], X[1], X[2]] then begin Ok[X[0], X[1], X[2]] := true; for i := 1 to 7 do R[X[0] * (i and 1) + X[1] * ((i shr 1) and 1) + X[2] * ( ( i shr 2 ) and 1)] := true; for i := 0 to 2 do if X[i] = 0 then begin X[i] := K[i]; Calc(X); X[i] := 0; end; for i := 0 to 2 do for j := 0 to 2 do if i <> j then begin d := min(K[i] - X[i], X[j]); if d = 0 then continue; inc(X[i], d); dec(X[j], d); Calc(X); dec(X[i], d); inc(X[j], d); end; end; end; var a: integer; begin
FillChar(R, Sizeof(R),0); FillChar(Ok, Sizeof(Ok),0); read(K[0], K[1], K[2]); Y[0] := 0; Y[1] := 0; Y[2] := 0; Calc(Y); Count := 0; for a := 1 to 1000 do if R[a] then begin // writeln(a); inc(count); end; writeln(count); end. |
|
|