ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1114. Boxes

Why I get WA? Pelase, help me!!!!!!!
Posted by Revenger and NSC 22 Dec 2001 13:05
There is my solution:

Program t1114;

Const MaxL=15;

Var Mas         :array[1..20,0..MaxL,0..MaxL]of comp;
    Ans         :comp;
    N,i,j,A,B,k :longint;
    u,v         :longint;

begin
Read(N,A,B);
for i:=1 to 20 do
 for j:=1 to MaxL do
  for k:=1 to MaxL do
   mas[i,j,k]:=0;
if A>0 then mas[1,A-1,B]:=1;
if B>0 then mas[1,A,B-1]:=1;
if (A>0)and(B>0) then mas[1,A-1,B-1]:=1;
mas[1,A,B]:=1;
for i:=2 to N do begin
 for j:=0 to MaxL do
  for k:=0 to MaxL do
   if mas[i-1,j,k]<>0 then begin
    for u:=0 to j do
     for v:=0 to k do
      mas[i,j-u,k-v]:=mas[i,j-u,k-v]+mas[i-1,j,k];
   end;
end;
Ans:=0;
for i:=0 to MaxL do
 for j:=0 to MaxL do
  Ans:=Ans+mas[N,i,j];
writeln(Ans:0:0);
end.
Re: I misunderstand the problem!
Posted by Revenger and NSC 22 Dec 2001 13:12
There is my AC solution:

Program t1114;

Const MaxL=15;

Var Mas         :array[1..20,0..MaxL,0..MaxL]of extended;
    Ans         :extended;
    N,i,j,A,B,k :longint;
    u,v         :longint;

begin
Read(N,A,B);
for i:=1 to 20 do
 for j:=1 to MaxL do
  for k:=1 to MaxL do
   mas[i,j,k]:=0;
for u:=0 to A do
 for v:=0 to B do
      mas[1,A-u,B-v]:=1;
for i:=2 to N do
 for j:=0 to MaxL do
  for k:=0 to MaxL do
   if mas[i-1,j,k]<>0 then
    for u:=0 to j do
     for v:=0 to k do
      mas[i,j-u,k-v]:=mas[i,j-u,k-v]+mas[i-1,j,k];
Ans:=0;
for i:=0 to MaxL do
 for j:=0 to MaxL do
  Ans:=Ans+mas[N,i,j];
writeln(Ans:0:0);
end.