关于pascal计算2^n……(1<=n<=31600000)`急!!!
答案:1 悬赏:80
解决时间 2021-03-16 04:14
- 提问者网友:酱爆肉
- 2021-03-15 10:11
关于pascal计算2^n……(1<=n<=31600000)`急!!!
最佳答案
- 二级知识专家网友:老鼠爱大米
- 2021-03-15 11:08
Var a,b,c:Array[1..201]Of word;i,j,k,m,n,p,t:Longint;BeginReadln(p);Writeln(Trunc(Ln(2)/Ln(10)*p)+1);k:=0;repeatinc(k);a[k]:=p mod 2;p:=p div 2until p=1;b[1]:=2;n:=1;for m:=k downto 1 dobeginfillchar(c,sizeof(c),0);for i:=1 to n dofor j:=1 to n dobeginif i+j-1>200 then break;t:=i+j-1;inc(c[t],b[i]*b[j]);inc(c[t+1],c[t] div 10);c[t]:=c[t]mod 10;end;if a[m]=1 thenbeginb:=c;fillchar(c,sizeof(c),0);for i:=1 to t dobeginc[i]:=c[i]+b[i]*2;if c[i]>9 then begin inc(c[i+1]);c[i]:=c[i]mod 10 end;end;end;n:=t+1;b:=cend;For i:=200 Downto 1 DoBeginWrite(c[i]);If i Mod 50=1 Then WritelnEnd;end.这类似于NOIP2003 第三道 “麦森数”
麻烦采纳,谢谢!
麻烦采纳,谢谢!
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯