bzoj 1002 找规律(基尔霍夫矩阵)
2013-11-23 09:52
225 查看
网上说的是什么基尔霍夫矩阵,没学过这个,打个表找下规律,发现
w[i]=3*w[i-1]-w[i-2]+2;
然后写个高精直接递推就行了
w[i]=3*w[i-1]-w[i-2]+2;
然后写个高精直接递推就行了
//By BLADEVIL var n :longint; a, b, c :array[0..100000] of longint; w :array[0..200] of ansistring; i :longint; function plus(s1,s2:ansistring):ansistring; var len :longint; i :longint; s :ansistring; begin fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); len:=length(s1); for i:=1 to len do a[(len-i) div 4+1]:=a[(len-i) div 4+1]*10+ord(s1[i])-48; len:=length(s2); for i:=1 to len do b[(len-i) div 4+1]:=b[(len-i) div 4+1]*10+ord(s2[i])-48; if length(s1)>len then len:=length(s1); len:=(len+3) div 4; for i:=1 to len do begin c[i]:=c[i]+a[i]+b[i]; c[i+1]:=c[i+1]+c[i] div 10000; c[i]:=c[i] mod 10000; end; inc(len); plus:=''; for i:=len downto 1 do begin str(c[i],s); if c[i]<1000 then plus:=plus+'0'; if c[i]<100 then plus:=plus+'0'; if c[i]<10 then plus:=plus+'0'; plus:=plus+s; end; while (plus[1]='0') and (length(plus)>1) do delete(plus,1,1); end; function jian(s1,s2:ansistring):ansistring; var len :longint; i :longint; s :ansistring; begin fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); len:=length(s1); for i:=1 to len do a[(len-i) div 4+1]:=a[(len-i) div 4+1]*10+ord(s1[i])-48; len:=length(s2); for i:=1 to len do b[(len-i) div 4+1]:=b[(len-i) div 4+1]*10+ord(s2[i])-48; len:=(length(s1)+3) div 4; for i:=1 to len do c[i]:=a[i]-b[i]; for i:=1 to len do if c[i]<0 then begin c[i]:=c[i]+10000; dec(c[i+1]); end; jian:=''; for i:=len downto 1 do begin str(c[i],s); if c[i]<1000 then jian:=jian+'0'; if c[i]<100 then jian:=jian+'0'; if c[i]<10 then jian:=jian+'0'; jian:=jian+s; end; while (jian[1]='0') and (length(jian)>1) do delete(jian,1,1); end; begin read(n); w[1]:='1'; w[2]:='5'; for i:=3 to n do w[i]:=plus(jian(plus(plus(w[i-1],w[i-1]),w[i-1]),w[i-2]),'2'); writeln(w ); end.
相关文章推荐
- bzoj 1002 [FJOI2007]轮状病毒 找规律/基尔霍夫矩阵
- bzoj 1002: [FJOI2007]轮状病毒(打表找规律或基尔霍夫矩阵)
- bzoj 1002 [FJOI2007]轮状病毒 高精度&&找规律&&基尔霍夫矩阵
- BZOJ 1002: [FJOI2007]轮状病毒【生成树的计数与基尔霍夫矩阵简单讲解+高精度】
- [bzoj1002] [FJOI2007]轮状病毒轮状病毒(基尔霍夫矩阵)
- 生成树的计数(基尔霍夫矩阵):BZOJ 1002 [FJOI2007]轮状病毒
- BZOJ 题目1002 [FJOI2007]轮状病毒(高精度+基尔霍夫矩阵)
- BZOJ 1002 矩阵树找规律递推高精度 解题报告
- BZOJ 1002 轮状病毒 (基尔霍夫矩阵)
- BZOJ 1002:[FJOI2007] 轮状病毒 (基尔霍夫矩阵生成树定理)
- BZOJ 1002([FJOI2007]轮状病毒-基尔霍夫矩阵)
- BZOJ 1002: [FJOI2007]轮状病毒 递推/基尔霍夫矩阵树定理
- 【BZOJ 4031】[HEOI2015]小Z的房间 基尔霍夫矩阵
- 【BZOJ1002】【高精度】【找规律】轮状病毒
- [BZOJ1002][FJOI2007]轮状病毒(打表找规律+高精度||结论)
- [bzoj1002][FJOI2007]轮状病毒【高精度】【矩阵树定理】
- BZOJ1002(FJOI2007)[轮状病毒]--找规律+高精度
- 【bzoj1002】【FJOI2007】【轮状病毒】【找规律】
- [bzoj1002]: [FJOI2007]轮状病毒(矩阵树定理)
- BZOJ 1002 FJOI 2007 轮状病毒 暴力+找规律+高精度