ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1036. Lucky Tickets

Why Compilation Error?
Posted by Evgeny 5 Jan 2003 16:37
program luckytickets;
var
  cur,nxt: array[0..1000,1..101] of byte;
  i,j,k,n,m,p: longint;
  res,buf : array[1..101] of byte;
procedure printing;
var i: integer;
fl: boolean;
begin
  fl := false;
  for i := 100 downto 1 do begin
    if res[i] <> 0 then fl := true;
    if fl then write(res[i]);
  end;
  if not fl then write('0');
  writeln;
end;
procedure summa(m,n: integer);
var i: integer;
begin
  fillchar(nxt[m],sizeof(nxt[m]),0);
  for i := 1 to 50 do begin
    nxt[m][i+1] := (nxt[m][i]+buf[i]+cur[n][i]) div 10;
    nxt[m][i] := (nxt[m][i]+buf[i]+cur[n][i]) mod 10;
  end;
end;
procedure Kvadrat(k : integer);
var i,j: integer;
begin
  for i := 1 to 50 do begin
    fillchar(buf,sizeof(buf),0);
    for j := 1 to 50 do begin
      buf[i+j] := buf[i+j] + cur[k][i]*cur[k][j] div 10;
      buf[i+j-1] := buf[i+j-1] + cur[k][i]*cur[k][j] mod 10;
    end;
    for j := 1 to 99 do begin
      res[j+1] :=res[j+1] + (res[j] + buf[j]) div 10;
      res[j] := (res[j] + buf[j]) mod 10;
    end;
  end;
end;
begin
  readln(n,k);
  if k mod 2 <> 0 then begin
    writeln('0');
    halt;
  end;
  k := k div 2;
  for i := 0 to 9 do begin
    cur[i][1] := 1;
  end;
  for i := 1 to n-1 do begin
    fillchar(nxt,sizeof(nxt),0);
    for p := 0 to 460 do begin
      for j := 0 to 9 do begin
        buf := nxt[p+j];
        summa(p+j,p);
      end;
    end;
    cur := nxt;
  end;
  Kvadrat(k);
  printing;
end.
Re: Why Compilation Error?
Posted by misha 14 Jan 2003 10:13
Actually, I do not know! I won't tell you "Nu i nakatal". You told me
you solved it!!!