Page 1 of 1

10970 - Big Chocolate

Posted: Wed Feb 14, 2007 8:37 pm
by m2lajoo
can you help me with this code?i don't know why it' WA

Code: Select all

var
a,b:longint;
function tedad(a,b:integer):integer;
begin
if (a=1)and(b=1) then
begin
tedad:=0;
exit;
end;
if (a=1) then
tedad:=b-1;
if (b=1) then
tedad:=a-1;
if (a<>1)and(b<>1) then
tedad:=(a-1)+tedad(1,b)*b;
end;
begin
while not eof(input) do
begin
readln(a,b);
writeln(tedad(a,b));
end;
end.

Re: 10970 why WA

Posted: Wed Feb 14, 2007 9:35 pm
by mf
m2lajoo wrote:tedad:=(a-1)+tedad(1,b)*b;
Perhaps, that should be
tedad:=(a-1)+tedad(1,b)*a;

Re: 10970 - Big Chocolate

Posted: Mon Mar 14, 2011 12:40 am
by DD
I think this problem may be the easiest problem ever. :D
It would be much more challenging if we are allowed to stack chocolate up and cut.