|
|
back to boardI got WA, please help me! Give some test! type long = record a:array[1..250]of byte; l:byte; end; arr = array[0..530]of long; parr = ^arr; var a:array[1..2]of parr; N,M:integer; procedure add(var a,b:long); var l,c,k,i:byte; begin k:=0; if a.l>b.l then l:=a.l else l:=b.l; for i:=1 to l do begin c:=a.a[i]; a.a[i]:=(c+b.a[i]+k)mod 10; k:=(c+b.a[i]+k)div 10; end; a.l:=i; if k<>0 then begin inc(a.l); a.a[a.l]:=K; end; end; procedure mul_i(var a:long;b:longint); var k:longint;c,i:byte; begin k:=0; for i:=1 to a.l do begin c:=a.a[i]; a.a[i]:=(c*b+k)mod 10; k:=(c*b+k)div 10; end; a.l:=i; while k<>0 do begin inc(a.l); a.a[a.l]:=K mod 10; k:=k div 10; end; end; procedure mul(var a:long); var tmp,_a:long; i,j:byte; begin fillchar(tmp,sizeof(tmp),0); for i:=1 to a.l do begin _a:=a; mul_i(_a,a.a[i]); for j:=_a.l downto 1 do _a.a[j+i-1]:=_a.a[j]; for j:=1 to i-1 do _a.a[j]:=0; _a.l:=_a.l+i-1; add(tmp,_a); end; a:=tmp; end; var i,j,k:integer; tmp:parr; begin { assign(input,'1036.dat');reset(input);} readln(N,M); if M mod 2 = 1 then begin writeln(0); halt; end else M:=M div 2; new(a[1]);new(a[2]); fillchar(a[1]^,sizeof(a[1]^),0); fillchar(a[2]^,sizeof(a[2]^),0); for i:=0 to 9 do begin a[1]^[i].a[1]:=1;a[1]^[i].l:=1;end; for i:=2 to N do begin for j:=0 to M do begin for k:=0 to 9 do if j-k>=0 then begin add(a[2]^[j],a[1]^[j-k]); end else break; end; tmp:=a[1];a[1]:=a[2];a[2]:=tmp; fillchar(a[2]^,sizeof(a[2]^),0); end; mul(a[1]^[M]); for i:=a[1]^[M].l downto 1 do write(a[1]^[M].a[i]); if a[1]^[M].l = 0 then write(0); writeln; dispose(a[1]);dispose(a[2]); end. |
|
|