#5359: jkljk6


lsfengjingxing (lsfengjingxing)

學校 : 上海市娄山中学
編號 : 18793
來源 : [103.220.77.6]
最後登入時間 :
2021-07-02 10:45:59
a134. 00948 - Fibonaccimal Base -- UVa948 | From: [115.173.237.7] | 發表日期 : 2011-07-14 09:33

var
  a : array[1..60,1..2] of qword;
  i,j,k,m,n,l,t : longint;
begin
    a[1,1] :=1;
    a[2,1] :=2;
    for i :=3 to 60 do a[i,1] :=a[i-1,1]+a[i-2,1];
    readln(m);
    for l :=1 to m do begin
      readln(n);k :=n;
      for i :=1 to 60 do a[i,2] :=0;
      i :=1;
      while a[i,1]<=n do inc(i);
      dec(i);
      while n>0 do begin
        j :=1;
        while a[j,1]<=n do inc(j);
        dec(j);
        n :=n-a[j,1];
        a[j,2] :=1
      end;
      write(k,' = ');
      for t :=i downto 1 do
        write(a[t,2]);
      writeln(' (fib)')
    end
end.

 

 

 
ZeroJudge Forum