|
|
вернуться в форумFor java,BigInteger works Re: For java,BigInteger works Послано aczovo 9 мар 2007 10:47 var a,b:array[1..1000]of longint; i,n,k,u,v,j:longint; begin for i:=1 to 100 do begin a[i]:=0; b[i]:=0; end; readln(n); readln(k); a[1]:=k-1; b[1]:=k*(k-1); u:=1; v:=1; for i:=3 to n do if (i mod 2=1) then for j:=1 to v do begin if 9*(a[j]+b[j])>=1000000000 then begin if j=v then u:=u+1; a[j+1]:=a[j+1]+1; end; a[j]:=9*(a[j]+b[j]) mod 1000000000 end else for j:=1 to u do begin if 9*(a[j]+b[j])>=1000000000 then begin if j=u then v:=v+1; a[j+1]:=a[j+1]+1; end; a[j]:=9*(a[j]+b[j]) mod 1000000000 end; if n mod 2=1 then for i:=u downto 1 do write(a[i]) else for i:=v downto 1 do write(b[i]); end. |
|
|