|
|
вернуться в форумWhy I get WA!!!I think I am right Послано rbecq 28 ноя 2002 12:36 type bignum=array[0..100] of byte; var n:byte; s,i,j,k:integer; f:array[0..500] of bignum; procedure add(var a:bignum;b:bignum); var i,r:byte; begin if a[0]<b[0] then a[0]:=b[0]; r:=0; for i:=1 to a[0] do begin a[i]:=a[i]+b[i]+r; r:=a[i] div 10; a[i]:=a[i] mod 10; end; if r>0 then begin inc(a[0]); a[a[0]]:=r end; end; procedure bsqr(var c:bignum); var a,b,t:bignum; i,j,r:byte; begin a:=c; b:=c; fillchar(c,sizeof(c),0); for i:=1 to a[0] do begin fillchar(t,sizeof(t),0); t[0]:=i+b[0]-1; r:=0; for j:=1 to b[0] do begin t[i+j-1]:=a[i]*b[j]+r; r:=t[i+j-1] div 10; t[i+j-1]:=t[i+j-1] mod 10; end; if r>0 then begin inc(t[0]); t[t[0]]:=r end; add(c,t); end; end; begin readln(n,s); if s mod 2=1 then begin writeln('0'); halt; end; s:=s div 2; fillchar(f,sizeof(f),0); for i:=0 to 9 do begin f[i][0]:=1; f[i][1]:=1; end; for i:=2 to n do for j:=s downto 0 do for k:=1 to 9 do begin if k>j then break; add(f[j],f[j-k]); end; bsqr(f[s]); for i:=f[s][0] downto 1 do write(f[s][i]); writeln; end. The size of your bignum is very small(only 100).Make it 200. |
|
|