讨论 / 发代码增RP
sser_cgb 2013-11-07 13:50:14
点我顶贴 收藏 删除
const chu=1000000007;

maxn=1000;

var n,m,k,ans,i,j,t,z:longint;

f:array[0..maxn,0..maxn]of int64;

d:int64;

function gcd(x,y:longint):longint;

begin

if y=0 then gcd:=x

else gcd:=gcd(y,x mod y);

end;

begin

readln(n,m,k);

f[0,0]:=1;

for i:=1 to n do f[0,i]:=1;

for i:=1 to m do f[i,0]:=1;

for i:=1 to m do

for j:=1 to n do

f[i,j]:=(f[i-1,j]+f[i,j-1]) mod chu;

for i:=0 to m do

for j:=0 to n do

begin

if i<>m then

begin

d:=f[m,n]-f[i,j]*f[m-i-1,n-j];

if d>0 then

begin

if d mod chu=k then inc(ans);

end

else begin

if abs(d) mod chu=chu-k then inc(ans);

end;

end;

if j<>n then

begin

d:=f[m,n]-f[i,j]*f[m-i,n-j-1];

if d>0 then

begin

if d mod chu=k then inc(ans);

end

else begin

if abs(d) mod chu=chu-k then inc(ans);

end;

end;

end;

t:=2*m*n+m+n;

if ans=0 then writeln(0)

else if t=ans then writeln(1)

else begin

z:=gcd(t,ans);

writeln(ans div z,'/',t div z);

end;

end.

#1 谧芒@2013-11-07 14:36:53
回复 删除
可否解释?
查看更多回复
提交回复