内容目录
高精Dp
Program P2506; type arr=record a:array[1..10000] of longint; len:longint; end; const base=1000; var i,j,n:longint; f:array[0..250] of arr; function max(a,b:longint):longint; begin if a<b then exit(b) else exit(a); end; Procedure add(a,b:arr;var c:arr); var i,j,len:longint; begin fillchar(c,sizeof(c),0); for i:=1 to max(a.len,b.len) do begin inc(c.a[i],a.a[i]+2*b.a[i]); inc(c.a[i+1],c.a[i] div base); c.a[i]:=c.a[i] mod base; end; i:=max(a.len,b.len); while (c.a[i+1]>0) do begin inc(i); inc(c.a[i+1],c.a[i] div base); c.a[i]:=c.a[i] mod base; end; while (i>1) and (c.a[i]=0) do dec(i); c.len:=i; end; begin fillchar(f,sizeof(f),0); for i:=0 to 250 do f[i].len:=1; f[1].a[1]:=1; f[0].a[1]:=1; for i:=2 to 250 do add(f[i-1],f[i-2],f[i]); while not eof do begin readln(n); write(f[n].a[f[n].len]); for i:=f[n].len-1 downto 1 do begin if f[n].a[i]<100 then write('0'); if f[n].a[i]<10 then write('0'); write(f[n].a[i]); end; writeln; end; end.