noip2007 矩阵取数
来源:互联网 发布:马里亚纳网络是什么 编辑:程序博客网 时间:2024/05/22 12:38
简单的DP+高精,
高精通过4个int64压位,效率还好,高精度的代价是4,小的忽略不计。
typenum=array[1..5]of int64;constmo=100000000;varn,m,i,j,l,k:longint;a:array[1..80]of longint;two:array[0..80] of num;f:array[1..80,1..80] of num;ans,t1,t2:num;function add_btb(a,b:num):num;varc:num;i:longint;x:int64;beginx:=0;for i:=1 to 4 do beginc[i]:=a[i]+b[i]+x;x:=c[i] div mo;c[i]:=c[i] mod mo;end;add_btb:=c;end;function mul_btc(a:num;b:int64):num;vari:longint;c:num;x:int64;beginx:=0;fillchar(c,sizeof(c),0);for i:=1 to 4 do beginc[i]:=a[i]*b+x;x:=c[i] div mo;c[i]:=c[i] mod mo;end;mul_btc:=c;end;function max(a,b:num):num;vari:longint;beginfor i:=4 downto 1 do beginif a[i]=b[i] then continue;if a[i]>b[i] then exit(a) else exit(b);end;end;procedure print(a:num);var i,k:longint;beginfor k:=4 downto 1 do if a[k]<>0 then break;for i:=k downto 1 do beginif i<>k then beginif a[i]<10000000 then write(0);if a[i]<1000000 then write(0);if a[i]<100000 then write(0);if a[i]<10000 then write(0);if a[i]<1000 then write(0);if a[i]<100 then write(0);if a[i]<10 then write(0);end;write(a[i]);end;writeln;end;beginreadln(n,m);two[0][1]:=1;for i:=1 to m do two[i]:=mul_btc(two[i-1],2);for k:=1 to n do beginfor i:=1 to m do beginread(a[i]);f[i,i]:=mul_btc(two[m],a[i]);end;for l:=1 to m-1 dofor i:=1 to m-l do beginj:=i+l;t1:=add_btb(f[i+1,j],mul_btc(two[m-j+i],a[i]));t2:=add_btb(f[i,j-1],mul_btc(two[m-j+i],a[j]));f[i,j]:=max(t1,t2);end;ans:=add_btb(ans,f[1,m]);end;print(ans);end.
- noip2007 矩阵取数
- 【NOIP2007】矩阵取数题解
- NOIP2007 矩阵取数游戏
- NOIP2007【矩阵取数游戏】
- NOIP2007矩阵取数游戏
- 【NOIP2007】矩阵取数游戏
- Noip2007矩阵取数游戏题解
- noip2007矩阵取数游戏 2008.11.5
- NOIP2007 矩阵取数 DP+高精度
- NOIP2007 矩阵取数游戏 [dp] [高精度]
- 【NOIP2007】洛谷1005 矩阵取数游戏
- 洛谷P1005&NOIP2007 矩阵取数游戏
- NOIP2007提高组 矩阵取数
- ACM 96. [NOIP2007] 矩阵取数游戏(dp+高精度)
- noip2007 矩阵取数游戏 (动态规划+高精度)
- NOIP2007提高组——矩阵取数游戏(game)
- NOIP2007 提高组 复赛 game 矩阵取数游戏
- [NOIP2007] 矩阵取数游戏 【记忆化搜索+高精】
- install 4
- Mutex和Semaphore区别
- c# 绘图设备和.net运行库的重绘节点
- install 5
- Android 上的消息推送通知(Push Notification)
- noip2007 矩阵取数
- Java初学者不得不知的概念,JDK,JRE,JVM的区别?
- Inet4Address类和Inet6Address类
- 也说eboot流程
- 【转】Android调试的必杀技——反汇编
- mysql实现sequence
- 网页选项卡/滑动门代码— — — — 淘宝网站的右侧
- Vi指令大全—-编辑文件
- 【Ubuntu】用vim来合并两个文件的命令