vj1378 矩阵取数游戏

Vj1378 矩阵取数游戏

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // //DP //f[i,j]=max(g[k,i]*2^(m-j+i)+f[i+1,j] , g[k,j]*2^(m-j+i)+f[i,j-1]) // / // // f[i,i]=g[k,i]*2^m / const maxp=20; maxn=80; base=10000; type bignum=record l:integer; a:array[0..maxp] of longint; end; var n,m:integer; g:array[0..maxn,0..maxn] of integer; ans,t1,t2,tmp:bignum; pow:array[0..maxn] of bignum; f:array[0..maxn,0..maxn] of bignum; function max(x,y:bignum):bignum; var i:integer; begin if x.l>y.l then exit(x); if x.l<y.l then exit(y); for i:=x.l downto 1 do begin if x.a[i]>y.a[i] then exit(x); if x.a[i]<y.a[i] then exit(y); end; exit(x); end; procedure add(var x:bignum; y:bignum); var i:integer; begin if y.l>x.l then x.l:=y.l; for i:=1 to x.l do begin inc(x.a[i],y.a[i]); if x.a[i]>=base then begin inc(x.a[i+1]); dec(x.a[i],base); end; end; if x.a[x.l+1]>0 then inc(x.l); end; procedure mul(var x:bignum; y:bignum); var i,j:integer; begin fillchar(tmp,sizeof(tmp),0); for i:=1 to x.l dofor i:=1 to x....
View Full Document

Page1 / 3

Vj1378 矩阵取数游戏

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online