9
9
2015
2

双高精度除法代码

贴段代码。高精度除高精度,P党什么的最有爱了。

var
	a, b, c : array[0..40000] of longint;
	i, j, k, l, m, n, lena, lenb, lenc : longint;
	s : ansistring;

function mo(w : longint) : boolean;
var
	i : longint;
begin
	if lena - w + 1 > lenb then exit(true);
	if lena - w + 1 < lenb then exit(false);
	for i := 0
 to lenb - 1 do
	begin
		if a[lena - i] > b[lenb - i] then exit(true);
		if a[lena - i] < b[lenb - i] then exit(false);
	end;
	mo := true;
end;

procedure minus(w : longint);
var
	i, j : longint;
begin
	j := 1;
	for i := w to w + lenb - 1 do
	begin
		if a[i] < b[j] then
		begin
			dec(a[i + 1]);
			inc(a[i],10 - b[j]);
		end else dec(a[i],b[j]);
		inc(j);
	end;
	while (lena > 0) and (a[lena] = 0) do dec(lena);
	if lena = 0 then lena := 1;
end;

begin
	readln(s);
	lena := length(s);
	for i := 1 to lena do a[lena - i + 1] := ord(s[i]) - 48;
	readln(s);
	lenb := length(s);
	for i := 1 to lenb do b[lenb - i + 1] := ord(s[i]) - 48;
	
	lenc := lena - lenb + 1;
	for i := lenc downto 1 do
		while mo(i) do
		begin
			minus(i);
			inc(c[i]);
		end;
	while (lenc > 0) and (c[lenc] = 0) do dec(lenc);
	if lenc = 0 then lenc := 1;
	
	for i:=lenc downto 1 do write(c[i]);
end.
Category: 未分类 | Tags: | Read Count: 798
Avatar_small
orz hhw 说:
2015年9月09日 20:41

%%%太神啦,快去学多项式除法!

Avatar_small
ICICI Credit Card Pa 说:
2022年8月06日 20:11

ICICI has become one of the largest banking services in India. This is essentially because of their financial options that they provide to customers. Among them ICICI credit card online payment option has become a prominent one with eligible customers. ICICI Credit Card Payment Making full use of different types of cards available and then being able to make through different payment gateway in quick time as well. If this is your first time making your ICICI bank credit card payment then you can go through this article below. You may discuss different methods available that can help you make your payment in no time.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com