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

At last I got AC!My Solution here:
Posted by Destiny 4 Nov 2002 08:31
program lucky;
const
 maxn=200;
type
 arraytype=array[0..maxn]of integer;
var
 p:array[0..1,0..500]of arraytype;
 b:arraytype;
 len:array[0..1,0..500]of integer;
 n,m,i:integer;
procedure init;
var
 i,j:integer;
begin
 readln(n,m);
 if odd(m) then
  begin
   writeln('0');
   halt;
  end;
 m:=m div 2;
 fillchar(p,sizeof(p),0);
 for i:=0 to m do
  for j:=0 to 1 do
   len[j,i]:=1;
 p[0,0,1]:=1;
end;
procedure add(x,y:integer);
var
 l,i:integer;
begin
 if len[1,x]>len[0,y] then
  l:=len[1,x]
 else
  l:=len[0,y];
 for i:=1 to l do
  begin
   p[1,x][i]:=p[1,x][i]+p[0,y][i];
   p[1,x][i+1]:=p[1,x][i+1]+p[1,x][i] div 10;
   p[1,x][i]:=p[1,x][i] mod 10;
  end;
 while p[1,x][l+1]<>0 do
  begin
   inc(l);
   p[1,x][l+1]:=p[1,x][l] div 10;
   p[1,x][l]:=p[1,x][l] mod 10;
  end;
 len[1,x]:=l;
end;
procedure solve;
var
 i,j,k,jj:integer;
begin
 for i:=1 to n do
  begin
   for j:=0 to m do
    for k:=0 to 9 do
     if (j+k<=m) and (j+k<>0) then
       add(j+k,j);
   p[0]:=p[1];
   p[0,0,1]:=1;
   len[0]:=len[1];
   len[0,1]:=1;
   fillchar(p[1],sizeof(p[1]),0);
  end;
end;
procedure square;
var
 i,j:integer;
begin
 fillchar(b,sizeof(b),0);
 for i:=1 to len[0,m] do
  for j:=1 to len[0,m] do
   begin
    b[i+j-1]:=b[i+j-1]+p[0,m,i]*p[0,m,j];
    b[i+j]:=b[i+j]+b[i+j-1] div 10;
    b[i+j-1]:=b[i+j-1] mod 10;
   end;
 len[0,m]:=2*len[0,m]-1;
 while b[len[0,m]+1]<>0 do
  begin
   inc(len[0,m]);
   b[len[0,m]+1]:=b[len[0,m]] div 10;
   b[len[0,m]]:=b[len[0,m]] mod 10;
  end;
 for i:=len[0,m] downto 1 do
  write(b[i]);
 writeln;
end;
begin
 init;
 solve;
 square;
end.


My Solution here:
Posted by Oleg 7 Jan 2003 06:37
var n:integer;
begin
 read(n);
 case n of
  2:writeln('10');
  4:writeln('670');
  6:writeln('55252');
  8:writeln('4816030');
 end;
end.
oy its 1044 solution
Posted by Oleg 7 Jan 2003 06:39
> var n:integer;
> begin
>  read(n);
>  case n of
>   2:writeln('10');
>   4:writeln('670');
>   6:writeln('55252');
>   8:writeln('4816030');
>  end;
> end.
>
Re: My Solution here:
Posted by Make me laugh 10 Jan 2003 17:22
> You are so crazy!?
Re: At last I got AC!My Solution here:
Posted by Chen Yuxi 14 May 2004 14:57
So long program...
Re: oy its 1044 solution
Posted by Don 6 Aug 2004 14:25
Can this AC?
Re: At last I got AC!My Solution here:
Posted by mitrandir 2 Apr 2007 18:14
Input:10 2
Your solution gives answer 0 but in my opinion right answer is 100(but, sure, not zero)