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 1079. Maximum

Can I Use "DIV 2" Instead Of "SHR 1" ?
Posted by Neo 11 Jun 2003 09:33
Here's my program, but I got WA. Can you give me some test datas?

const
  Maxn = 100000;
var
  N,Max : Longint;

procedure Cal;
var i:Longint;a:array[0..Maxn] of Longint;
begin
  a[0]:=0;a[1]:=1;
  Max := -maxlongint;
  for i:=2 to N do
    begin
      If i mod 2=0 then a[i]:=a[i div 2] else a[i]:=a[i div 2]+a[(i
div 2)+1];
      If a[i]>Max then Max:=a[i];
    end;
end;

begin
  Readln(N);
  repeat
    Cal;
    Writeln(Max);
    Readln(n);
  until N=0;
end.
Re: Can I Use "DIV 2" Instead Of "SHR 1" ?
Posted by HermesWang 2 May 2004 15:02
I don't think you get WA,but I think you do lots of things usefulless.
For example:
9
10
11
12
13
14
15
0
here your program caculate 9 seven times.
Re: Can I Use "DIV 2" Instead Of "SHR 1" ?
Posted by Dulat_TKTL 27 Jan 2006 19:52
shr 1 I think