vj1378 &ccedil;Ÿ&copy;&eacute;˜&micro;&aring;–&aelig;•&deg;&aelig;&cedil;&cedil;&aelig;ˆ

# Vj1378 &ccedil;Ÿ&copy;&eacute;˜&micro;&aring;–&aelig;•&deg;&aelig;&cedil;&cedil;&aelig;ˆ

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

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

View Full Document
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&amp;gt;y.l then exit(x); if x.l&amp;lt;y.l then exit(y); for i:=x.l downto 1 do begin if x.a[i]&amp;gt;y.a[i] then exit(x); if x.a[i]&amp;lt;y.a[i] then exit(y); end; exit(x); end; procedure add(var x:bignum; y:bignum); var i:integer; begin if y.l&amp;gt;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]&amp;gt;=base then begin inc(x.a[i+1]); dec(x.a[i],base); end; end; if x.a[x.l+1]&amp;gt;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

## Vj1378 &ccedil;Ÿ&copy;&eacute;˜&micro;&aring;–&aelig;•&deg;&aelig;&cedil;&cedil;&aelig;ˆ

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

View Full Document
Ask a homework question - tutors are online