如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。

URAL/1079

来自"NOCOW"

跳转到: 导航, 搜索
VAR
  a,f:array [0..100000] of longint;
  i,n:longint;
Function Max(a,b:longint):longint;
BEGIN
  if a>b then exit(a)
    else exit(b);
END;
BEGIN
  a[0]:=0;
  a[1]:=1;
  f[0]:=0;
  f[1]:=1;
    for i:=2 to 100000 do
      BEGIN
        if not odd(i) then a[i]:=a[i div 2]
          else a[i]:=a[i div 2]+a[i div 2+1];
        f[i]:=Max(f[i-1],a[i]);
      END;
    while true do
      BEGIN
        readln(n);
          if n=0 then halt;
        writeln(f[n]);
      END;
END.
个人工具