ac1059.pas

来自「这是在网络上搜集到的在东京大学的ACM上面解决的一些题目的源码」· PAS 代码 · 共 45 行

PAS
45
字号
program tju1059;
const
  half=1500000;
var
  s:array[0..half,0..2]of int64;
  n,i:longint;
  base:int64;
procedure tail(a:int64);
  var
    s:string;
    i:byte;
  begin
    str(a,s);
    for i:=length(s) to 17 do write('0');
    write(s);
  end;
procedure out(a,b,c:int64);
  begin
    if a>0 then begin
      write(a);tail(b);tail(c);
    end
    else if b>0 then begin
      write(b);tail(c);
    end
    else
      write(c);
    writeln;
  end;
begin
  base:=power(10,9);base:=base*base;
  s[0,0]:=1;
  for n:=1 to half do
    for i:=0 to 2 do begin
      inc(s[n,i],s[n-1,i]+s[n shr 1,i]);
      if s[n,i]>=base then begin
        inc(s[n,i+1]);dec(s[n,i],base);
      end;
    end;

  repeat
    read(n);n:=n shr 1;
    out(s[n,2],s[n,1],s[n,0]);
  until seekeof;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?