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

Plz help !!! Test #10 WA
Posted by Shyrik 25 Sep 2007 11:49
{My solution }

type
  tlong = record
    k : integer;
    x : array [0..500] of longint;
  end;

const
  base = 1000000000;

var
  f : array [0..54,0..1110] of tlong;
  n,m,i,j,z : longint;
  c : array [0..20000] of longint;
  st,s : ansistring;

Procedure Sum(a,b : tlong; var c : tlong);
var i : longint;
begin
  if a.k>b.k then c.k:=a.k else c.k:=b.k;
  for i:=1 to c.k do c.x[i]:=a.x[i]+b.x[i];
  for i:=1 to c.k do
  if c.x[i]>=base then
  begin
    inc(c.x[i+1]);
    dec(c.x[i],base);
  end;
  if c.x[c.k+1]>0 then inc(c.k);
end;

begin
  read(n,m);
  if odd (m) then writeln('0') else
  begin
    m:=m shr 1;
    for i:=1 to n do
    for j:=0 to m do f[i,j].k:=1;

    for i:=0 to 9 do f[1,i].x[1]:=1;

    for i:=2 to n do
    for j:=0 to 9 do
    for z:=0 to m-j do
      sum(f[i,z+j],f[i-1,z],f[i,z+j]);

    st:='';
    str(f[n,m].x[f[n,m].k],st);
    for i:=f[n,m].k-1 downto 1 do
    begin
      str(f[n,m].x[i],s);
      for j:=8 downto length(s) do st:='0'+st;
      st:=st+s;
    end;

    s:='';
    for i:=length(st) downto 1 do s:=s+st[i];

    fillchar(c,sizeof(c),0);

    for i:=1 to length(s) do
    for j:=1 to length(s) do
    inc(c[i+j-1],(ord(s[i])-48)*(ord(s[j])-48));

    for i:=1 to 2*length(s)+1 do
    begin
      inc(c[i+1],c[i] div 10);
      c[i]:=c[i] mod 10;
    end;

    j:=2*length(s)+100;
    while (c[j]=0) and (j>1) do dec(j);

    for i:=j downto 1 do write(c[i]);
    writeln;
  end;
end.
Re: Plz help !!! Test #10 WA
Posted by Razdolbay from SIS 25 Sep 2007 18:09
Test: 50 50
Right answer: 1228576490354119571810717714807944388004
Your answer:  12609995031366898184717714807944388004