ENG  RUS Timus 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 my code WA#7>????? Need help?Who know the test for #7?
Posted by zslwyuan 6 Jan 2010 10:49
type
sl=array[1..150] of longint;
var
i,j,k,l,n,m,s:longint;
f:array[0..50,-10..1000] of sl;
u:sl;
function gjc(a:sl):sl;
var
i,t:longint;
tmp:sl;
begin
for i:=120 downto 1 do
if a[i]<>0 then break;
t:=i;
fillchar(tmp,sizeof(tmp),0);
for i:=1 to t do
for j:=1 to t do
inc(tmp[i+j-1],a[i]*a[j]);
for i:=1 downto 120 do
begin
tmp[i+1]:=tmp[i+1]+tmp[i] div 10000;
tmp[i]:=tmp[i] mod 10000;
end;
exit(tmp);
end;

procedure gjj(b:sl;var a:sl);
var
i,j,k,l:longint;

begin
for i:=1 to 120 do
a[i]:=a[i]+b[i];
for j:=1 to 120 do
begin
inc(a[j+1],a[j] div 10000);
a[j]:=a[j] mod 10000;
end;
end;

procedure printgj(a:sl);
var
i,j,k,l,len:longint;
st:string;
begin
i:=120;
while (i>0)and(a[i]=0) do dec(i);
if i=0 then BEGIN writeln(0);exit;end;
len:=i-1;
write(a[len+1]);
for i:=len-1 downto 1 do
begin
str(a[i],st);
while length(st)<4 do insert('0',st,1);
write(st);
end;
end;

begin
readln(n,s);
if (n=1)and(s<=9) then begin writeln(1);halt; end;
if s mod 2=1 then begin writeln(0);halt; end;
f[0,0][1]:=1;
for i:=1 to n do
for j:=0 to s shr 1 do
for k:=0 to 9 do
begin
gjj(f[i-1,j-k],f[i,j]);
end;
l:=s shr 1;
u:=(gjc(f[n,l]));
printgj(u);
end.

Edited by author 07.01.2010 10:17
Re: Why my code WA#7>????? Need help?Who know the test for #7?
Posted by SuperLight 6 Jan 2010 18:55