bzoj1089: [SCOI2003]严格n元树
来源:互联网 发布:中国那个朝代最弱知乎 编辑:程序博客网 时间:2024/06/04 18:40
传送门
设f[i]表示深度小于等于i的树的个数。
得到公式
f[i]=f[i-1]^n+1
答案就是f[d]-f[d-1];
高精度水过。
type arr=array [0..5005] of int64;var f:array [0..20] of arr; n,d,i:longint;procedure cheng(a,b:arr; var c:arr); var i,j:longint; x:int64; begin fillchar(c,sizeof(c),0); for i:=1 to a[0] do begin x:=0; for j:=1 to b[0] do begin x:=c[i+j-1]+x+a[i]*b[j]; c[i+j-1]:=x mod 100000000; x:=x div 100000000; end; c[i+b[0]]:=x; end; if (c[a[0]+b[0]]<>0) then c[0]:=a[0]+b[0] else c[0]:=a[0]+b[0]-1; end;procedure mi(x:longint); begin if (x=1) then exit; mi(x div 2); cheng(f[i],f[i],f[i]); if x mod 2=1 then cheng(f[i],f[i-1],f[i]); exit; end;procedure jiayi; var j:longint; begin inc(f[i,1]); for j:=1 to f[i,0] do begin inc(f[i,j+1],f[i,j] div 100000000); f[i,j]:=f[i,j] mod 100000000; end; if (f[i,f[i,0]+1]<>0) then inc(f[i,0]); end;procedure jian; var i:longint; begin for i:=1 to f[d,0] do f[d,i]:=f[d,i]-f[d-1,i]; for i:=1 to f[d,0] do if f[d,i]<0 then begin inc(f[d,i],100000000); dec(f[d,i+1]); end; while (f[d,0]<>1) and (f[d,f[d,0]]=0) do dec(f[d,0]); end;procedure print; var i:longint; begin write(f[d,f[d,0]]); for i:=f[d,0]-1 downto 1 do begin if f[d,i]<10000000 then write(0); if f[d,i]<1000000 then write(0); if f[d,i]<100000 then write(0); if f[d,i]<10000 then write(0); if f[d,i]<1000 then write(0); if f[d,i]<100 then write(0); if f[d,i]<10 then write(0); write(f[d,i]); end; end;begin read(n,d); if d=0 then begin write(1); exit; end; f[0,0]:=1; f[0,1]:=1; for i:=1 to d do begin f[i]:=f[i-1]; mi(n); jiayi; end; jian; print;end.
0 0
- 【SCOI2003】【BZOJ1089】严格n元树
- bzoj1089-[SCOI2003]严格n元树
- bzoj1089: [SCOI2003]严格n元树
- bzoj1089 [SCOI2003]严格n元树
- [BZOJ1089][SCOI2003][递推][高精度]严格n元树
- 【BZOJ1089】[SCOI2003]严格n元树【递推】【高精度】
- BZOJ1089——[SCOI2003]严格n元树
- [BZOJ1089][SCOI2003]严格n元树(递推+高精度)
- BZOJ1089 [SCOI2003]严格n元树 【dp + 高精】
- BZOJ1089(SCOI2003)[严格n元树]--递推+高精度
- [BZOJ1089][SCOI2003]严格n元树(dp+数学相关+高精度)
- SCOI2003【严格n元树】
- 【题解】[scoi2003]严格n元树
- 【BZOJ 1089】 [SCOI2003]严格n元树
- 1089: [SCOI2003]严格n元树
- 1089: [SCOI2003]严格n元树
- 1089: [SCOI2003]严格n元树
- BZOJ 1089 SCOI2003 严格n元树 动态规划+高精度
- 占点游戏(数学)
- Android中XUtils3详细使用及介绍
- ignite使用sql查询的问题
- phpcms模板中显示内容数据
- 怎么在Editplus配置PHP(超详细)
- bzoj1089: [SCOI2003]严格n元树
- 精通Oracle SQL(第二版)读书笔记
- spring boot 配置静态资源
- tinyumbrella 9(小雨伞)无法打开(Crash、自动关闭)的解决方法
- SQL Server中关于跟踪(Trace)那点事
- HDU 4849 nyist省赛选拔题目
- 每天一个Linux命令(7):mv命令
- Dev的GridControl数值列如何设置百分数
- org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/l