记录编号 14240 评测结果 AAAAAAAAAA
题目名称 [NOIP 2003]麦森数 最终得分 100
用户昵称 GravatarEnAsn 是否通过 通过
代码语言 Pascal 运行时间 0.836 s
提交时间 2009-10-28 10:00:56 内存使用 0.13 MiB
显示代码纯文本
program ex;
type
 ss=array[1..1000]of longint;
var
 a,b,c,d:ss;
 p:longint;
procedure init;
 begin
  assign(input,'mason.in');
  assign(output,'mason.out');
  reset(input);
  rewrite(output);
  readln(p);
  close(input);
 end;
procedure dc;
 var
  i,j:longint;
 begin
  b:=a;
  fillchar(c,sizeof(c),0);
  for i:=1 to 500 do
   for j:=1 to 500 do
    begin
     c[i+j-1]:=c[i+j-1]+b[i]*a[j];
     if c[i+j-1]>=10 then
      begin
       c[i+j]:=c[i+j]+c[i+j-1]div 10;
       c[i+j-1]:=c[i+j-1]mod 10;
      end;
    end;
  a:=c;
 end;
procedure c2;
 var
  i,j,x:longint;
 begin
  x:=0;
  for i:=1 to 500 do
   begin
    a[i]:=a[i]*2;
    a[i]:=a[i]+x;
    x:=0;
    if a[i]>=10 then
     begin
      x:=a[i]div 10;
      a[i]:=a[i]mod 10;
     end;
   end;
 end;
procedure main;
 var
  i,j:longint;
  t1,t2,pp:longint;
 begin
  pp:=p;t1:=0;
  while pp<>0 do
   begin
    inc(t1);
    if pp mod 2<>0 then inc(d[t1]);
    pp:=pp div 2;
   end;
  a[1]:=2;
  for i:=t1-1 downto 1 do
   begin
    dc;
    if d[i]=1 then c2;
   end;
  dec(a[1]);
  writeln(trunc(p*ln(2)/ln(10))+1);
  j:=0;
  for i:=500 downto 1 do
   begin
    inc(j);
    if j=50 then begin
                  writeln(a[i]);
                  j:=0;
                 end
                 else write(a[i]);
   end;
  close(output);
 end;
begin
 init;
 main;
end.