pascal 高精度压位(加减乘&高精除单精)
来源:互联网 发布:歧视 美国 数据 编辑:程序博客网 时间:2024/05/01 00:55
program pro;type mine=array[0..1000000]of int64;var s1,s2:ansistring; n1,n2:mine; nn,i,j:longint;procedure insert(st:ansistring; var x:mine);var len:longint;begin len:=length(st); while len>=4 do begin inc(x[0]); val(copy(st,len-3,4),x[x[0]]); dec(len,4); end; if len>0 then begin inc(x[0]); val(copy(st,1,len),x[x[0]]); end;end;procedure plus(var a:mine; b:mine);var ii,jj:longint; c:mine;begin fillchar(c,sizeof(c),0); if a[0]<b[0] then c[0]:=b[0] else c[0]:=a[0]; for ii:=1 to c[0] do begin c[ii+1]:=c[ii+1]+(c[ii]+a[ii]+b[ii])div 10000; c[ii]:=(c[ii]+a[ii]+b[ii])mod 10000; end; while c[c[0]+1]>0 do inc(c[0]); a:=c;end;procedure minus(var a:mine; b:mine);var ii,jj:longint; c:mine;begin fillchar(c,sizeof(c),0); if a[0]<b[0] then c[0]:=b[0] else c[0]:=a[0]; for ii:=1 to c[0] do begin c[ii]:=c[ii]+a[ii]-b[ii]; if c[ii]<0 then begin inc(c[ii],10000); dec(c[ii+1]); end; end; while (c[0]>1)and(c[c[0]]=0) do dec(c[0]); a:=c;end;procedure mul(var a:mine; b:mine);var ii,jj:longint; c:mine;begin fillchar(c,sizeof(c),0); c[0]:=a[0]+b[0]-1; for ii:=1 to a[0] do for jj:=1 to b[0] do begin c[ii+jj]:=c[ii+jj]+(c[ii+jj-1]+a[ii]*b[jj])div 10000; c[ii+jj-1]:=(c[ii+jj-1]+a[ii]*b[jj])mod 10000; end; while c[c[0]+1]>0 do inc(c[0]); a:=c;end;procedure divv(var a:mine; b:int64);var ii:longint; xx:int64; c:mine;begin xx:=0; fillchar(c,sizeof(c),0); c[0]:=a[0]; for ii:=a[0] downto 1 do begin c[ii]:=xx*10000+a[ii]; xx:=c[ii] mod b; c[ii]:=c[ii] div b; end; while (c[0]>1)and(c[c[0]]=0)do dec(c[0]); a:=c;end;procedure print(a:mine);var ii:longint;begin write(a[a[0]]); for ii:=a[0]-1 downto 1 do begin if a[ii]<1000 then write(0); if a[ii]<100 then write(0); if a[ii]<10 then write(0); write(a[ii]); end;end;beginassign(input,'test.in'); reset(input);assign(output,'testyw.out'); rewrite(output); readln(s1); readln(s2);readln(nn); insert(s1,n1); insert(s2,n2); divv(n1,nn); print(n1);close(input);close(output);end.
0 0
- pascal 高精度压位(加减乘&高精除单精)
- 【高精度模板】【高精加减乘没有除】
- 高精度加减乘模版
- 高精度加减乘运算
- 【模板】高精度--加减乘
- 高精度(加减乘)改
- 高精度之高精除低精
- 转载高精度加减乘除法
- 【模板】高精度(加减乘)
- 高精度除法(高精除高精)
- 【基础代码】高精{加.减.乘.除}
- 高精度乘单精度
- 高精度除单精度
- POJ-1405 Heritage-高精度加减乘
- 【模板】高精度 加减乘 重载法
- 【高精度计算】加减乘模板(水)
- 高精度乘单精度 poj1001
- 高精度 加、减、乘、除 模板
- 有效的STL学习记录
- 编辑文章 - 博客频道 - CSDN.NET
- 后台进程---CKPT SMON PMON RECO ARCn
- TCP/IP协议-1
- Intent数据传递
- pascal 高精度压位(加减乘&高精除单精)
- [MVC4]Data Annotations Extensions:无法使用EmailAddress等验证特性的解决方法
- Redis源码分析(十五)——持久化AOF
- 动态规划算法----实现最长子序列
- java中字符集的问题
- 静态assert
- appcompat_v7/res/values-v21/themes_base.xml No resource found that matches the given name
- 自我练习(一)
- jdbc批处理