## 10970 - Big Chocolate

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

m2lajoo
New poster
Posts: 11
Joined: Thu Jan 11, 2007 9:21 am
Location: iran

### 10970 - Big Chocolate

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.
``````

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

### Re: 10970 why WA

m2lajoo wrote:tedad:=(a-1)+tedad(1,b)*b;
Perhaps, that should be
tedad:=(a-1)+tedad(1,b)*a;

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

### Re: 10970 - Big Chocolate

I think this problem may be the easiest problem ever.
It would be much more challenging if we are allowed to stack chocolate up and cut.
Have you ever...
• Wanted to work at best companies?
• Struggled with interview problems that could be solved in 15 minutes?
• Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.