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 1088. Ilya Murometz

WA#8,Help!
Posted by Takuma 14 Aug 2007 14:34
This is my code.I think there is no problem,but I got WA#8.
Who can find the mistake for me?
Thanks very much.

program u1088;
 const d:array[0..30]of longint=
  (0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,
  262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,
  134217727,268435455,536870911,1073741823);
 var f,h,hi,i,j,k:longint;
     p,l:array[1..2]of longint;{[1]d;[2]e; p:d; l:long; b:N-th}
     b:array[1..2]of longint;
procedure hs(i:longint;flag:boolean);
begin
 if flag then inc(hi);
 b[i]:=b[i] div 2;
end;
Begin
 read(l[1],l[2],f,p[1],p[2],h);
 for i:=1 to 2 do
  begin
   if (l[i]>f) or (p[i]>d[f]+1) then begin writeln('NO'); halt; end;
   b[i]:=p[i]+d[f];
   for j:=1 to l[i] do hs(i,false);
  end;
 if l[1]<l[2] then begin i:=1; j:=2; end
              else begin i:=2; j:=2; end;
 hi:=0;
 for k:=1 to l[j]-l[i] do hs(i,true);
 while b[1]<>b[2] do
  for i:=1 to 2 do hs(i,true);
 if hi<=h then writeln('YES')
          else writeln('NO');
End.
Re: WA#8,Help!
Posted by Tural Neymanov 6 Feb 2008 09:58
Maybe you should do: flag:=false(or true).
other way it will be random.