|
|
вернуться в форумCan I Use "DIV 2" Instead Of "SHR 1" ? Послано Neo 11 июн 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" ? 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" ? shr 1 I think |
|
|