A*B Problem
来源:互联网 发布:mac导入照片到ipad 编辑:程序博客网 时间:2024/05/01 05:16
分析
要用高精度,数组一定要开得大。我做的时候,就是因为数组不够大而和我朋友调试了超久。
const
maxn=2600;
var
a,b:array[1..maxn]of longint;
c:array[1..2*maxn]of longint;
l1,l2:longint;
procedure init;
var
s1,s2:ansistring;
i:longint;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
readln(s1);
readln(s2);
l1:=length(s1);
l2:=length(s2);
for i:=l1 downto 1 do
a[l1-i+1]:=ord(s1[i])-ord('0');
for i:=l2 downto 1 do
b[l2-i+1]:=ord(s2[i])-ord('0');
end;
procedure main;
var
i,j:longint;
begin
for i:=1 to maxn do
begin
for j:=1 to maxn do
begin
c[i+j-1]:=a[i]*b[j]+c[i+j-1];
c[i+j]:=c[i+j]+c[i+j-1] div 10;
c[i+j-1]:=c[i+j-1] mod 10;
end;
end;
end;
procedure print;
var
i,j:longint;
begin
i:=maxn;
while (c[i]=0)and(i>1) do dec(i);
for j:=i downto 1 do
write(c[j]);
end;
begin
init;
main;
print;
end.
- problem 1000: A+B problem
- Problem 1000 A+B Problem
- Problem - 1000 A + B Problem
- A + B Problem
- A + B Problem
- 1000 A+B Problem
- 1001 A + B Problem
- A+B Problem
- 1000 A+B Problem
- A + B Problem
- A + B Problem
- 1000 A + B Problem
- 1000 A+B Problem
- A + B Problem
- A + B Problem II
- A + B Problem II
- POJ1001 -- A-B Problem
- A + B problem II
- BFS入门-A计划
- linux系统——目录,目录项,索引节点(i node)的关系
- 建立live555海思编码推流服务
- Maven构建springMVC
- 算法竞赛入门经典 习题2-6 调和级数(harmony)
- A*B Problem
- 有无序的实数列V[N],要求求里面大小相邻的实数的差的最大值,关键是要求线性空间和线性时间。
- 前端工程目录
- 字符统计
- 流式布局代码块
- warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
- Linux基础命令大全
- input标签常使用记录
- HTML标签