比赛 |
暑假培训一 |
评测结果 |
WWAAAAAWWW |
题目名称 |
麦森数 |
最终得分 |
50 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-17 11:39:54 |
显示代码纯文本
program cch(input,output,f1,f2);
var
f1,f2:text;
p,i:integer;
a,l:array[0..500] of integer;
procedure add1;
var
i,j:integer;
b:array[0..500] of integer;
begin
fillchar(b,sizeof (b),0);
for i:=0 to 499 do
for j:=0 to 499-i do
inc(b[i+j],a[i]*l[j]);
for i:=0 to 498 do begin
inc(b[i+1],b[i] div 10);
b[i]:=b[i] mod 10;
end;
b[499]:=b[499] mod 10;
for i:=0 to 499 do a[i]:=b[i];
end;
procedure add2;
var
i,j:integer;
l1:array[0..499] of integer;
begin
fillchar(l1,sizeof (l1),0);
for i:=0 to 499 do
for j:=0 to 499-i do inc(l1[i+j],l[i]*l[j]);
for i:=0 to 498 do
begin
inc(l1[i+1],l1[i] div 10);
l1[i]:=l1[i] mod 10;
end;
l1[499]:=l1[499] mod 10;
for i:=0 to 499 do l[i]:=l1[i];
end;
begin
assign(f1,'mason.in');
assign(f2,'mason.out');
reset(f1);
rewrite(f2);
readln(f1,p);
writeln(f2,trunc(p*ln(2)/ln(10)+1));
fillchar(l,sizeof (l),0);
fillchar(a,sizeof (a),0);
l[0]:=2; a[0]:=1;
while p>0 do begin
if p mod 2=1 then add1;
p:=p div 2;
add2;
end;
dec(a[0]);
for i:=499 downto 0 do begin
write(f2,a[i]);
if i mod 50=0 then writeln(f2);
end;
close(f1);
close(f2);
end.