pascal计算范围有多大
pascal吧
全部回复
仅看楼主
level 9
如题,怎么我算50!都算不出来
2013年02月09日 09点02分 1
level 9
原来它只能算到7!
2013年02月10日 06点02分 2
level 13
。。。你要是用int64 你看能算到多少。。。非要用integer你怪谁?一般都用longint。。
2013年02月10日 06点02分 3
level 8
但我小学还不知道longint,结果打integer打惯了。现在longint只有考NOIP才打。
2013年02月11日 07点02分 5
level 9
50!都得用高精度了。。。
2013年02月11日 10点02分 6
怎么用?
2013年02月11日 13点02分
不用的吧。int64..or qword就行了吧
2013年02月18日 03点02分
level 12
发程序

还有
建议用qword
2013年02月11日 11点02分 7
qword 是什么?
2013年02月11日 13点02分
回复 黑榜o玄月xxl :FP的类型,可算0~2^64-1
2013年02月11日 13点02分
qword估计最多21!吧 PS:int64也不弱啊,-2^63~2^63
2013年02月11日 14点02分
回复 fp4869 :qword和int64好像差不多
2013年02月11日 14点02分
level 9
int64也只能算到20!
2013年02月11日 13点02分 8
level 12
dword
2013年02月11日 14点02分 9
注册表写多了吧你?
2013年02月16日 12点02分
回复 companion855 :没写过
2013年02月17日 05点02分
level 9
var
n,w,j,x,i:longint;
a:array [1..1000] of longint;
begin
readln(n);w:=1;a[1]:=1;
for i:=1 to n do
begin
x:=0;
for j:=1 to w do begin
a[j]:=a[j]*i+x;
x:=a[j] div 10;
a[j]:=a[j] mod 10;
end;
while x>0 do
begin
w:=w+1;
a[w]:=x mod 10;
x:=x div 10;
end;
end;
for i:=w downto 1 do
write(a[i]);
end.
2013年02月11日 14点02分 10
RT。。。高精度阶乘
2013年02月11日 14点02分
编译试试吧。。。可能会有错。
2013年02月11日 14点02分
回复 可否考虑q :看不懂耶
2013年02月11日 14点02分
回复 黑榜o玄月xxl :恩。。。1到n依次相乘,x表示上次进位,a数组表示n!的每一位,最后向最高位进位。
2013年02月11日 14点02分
level 9
2013年02月11日 14点02分 11
n你输了多少
2013年02月11日 15点02分
回复 fp4869 :20
2013年02月13日 05点02分
20!int64可以的
2013年02月13日 05点02分
回复 可否考虑q :只能到20! 我想算50! 上面的高精度阶乘我有点看不懂
2013年02月13日 09点02分
level 11
用高精阶乘吧~
2013年02月13日 06点02分 12
level 9
@可否考虑q
你写的我试过了,是对的。
我有几个问题
1、一开始那个“for j:=1 to w do”有什么用啊,一开始w不是等于1吗,而且后面的while循环条件也不成立啊
“begin
x:=0;
for j:=1 to w do begin
a[j]:=a[j]*i+x;
x:=a[j] div 10;
a[j]:=a[j] mod 10;
end;”这个执行之后什么都没变啊
2、我在输入电脑的时候删去了“for i:=1 to n do”后面的begin和有一个end,把“x:=0”放到了“for j:=1 to w do”后面,结果输出的值都是0,为什么会这样?
2013年02月13日 14点02分 13
@黑榜o玄月xxl 1.w表示位数,for j:=1 to w do表示从最后一位一直乘到第一位
2013年02月14日 06点02分
level 9
2.(你说的是这样吧)
var
n,w,j,x,i:longint;
a:array [1..1000] of longint;
begin
readln(n);w:=1;a[1]:=1;
for i:=1 to n do
for j:=1 to w do begin
x:=0;
a[j]:=a[j]*i+x;
x:=a[j] div 10;
a[j]:=a[j] mod 10;
end;
while x>0 do
begin
w:=w+1;
a[w]:=x mod 10;
x:=x div 10;
end;
for i:=w downto 1 do
write(a[i]);
end.
2013年02月14日 06点02分 14
这样的话进位就不能实现了 while x>0 do begin w:=w+1; a[w]:=x mod 10; x:=x div 10; end; 这段语句没有执行
2013年02月14日 06点02分
回复 可否考虑q :并且x一直赋值为0,上一次的进位也就一直是0
2013年02月14日 06点02分
level 6
高精度不解释
2013年02月16日 07点02分 15
level 9
@ 可否考虑q
谢谢,我懂了
2013年02月16日 08点02分 16
level 1
var n,i,j:longint;
a:array[0..5000]of longint;
begin
fillchar(a,sizeof(a),0);
readln(n);a[5000]:=1;
for i:=2 to n do
begin
for j:=5000 downto 1 do a[j]:=a[j]*i;
for j:=5000 downto 2 do
begin
a[j-1]:=a[j-1]+a[j]div 10;
a[j]:=a[j]mod 10;
end;
end;
i:=0;
while a[i]=0 do inc(i);
for j:=i to 5000 do write(a[j]);writeln;
readln;
end.
(300以内均可)
2014年08月02日 14点08分 17
level 13
要写高精度
2014年08月03日 04点08分 18
level 2
看来只能放最终法宝了,comp
2014年08月03日 08点08分 19
1