讨论 / 保持队形 发代码增RP @fshp971 @cgb
xmt459 2013-11-07 02:38:24
点我顶贴 收藏 删除
program aa;

const

magic:int64=1000000007;

var

f:array[-1..1005,-1..1000] of int64;

n,m,k:longint;

i,j:longint;

t:longint;

r:longint;

function cgb(n,m:longint):longint;

begin

if m=0 then exit(n) else exit(cgb(m,n mod m));

end;

begin

fillchar(f,sizeof(f),0);

readln(n,m,k);

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

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

for i:=1 to n do

for j:=1 to m do

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

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

r:=0;

for i:=0 to n do

for j:=0 to m do

begin

if ((f[n,m]-(f[i-1,j])*f[n-i,m-j] mod magic+magic) mod magic)=k then inc(r);

if ((f[n,m]-(f[i,j-1])*f[n-i,m-j] mod magic+magic) mod magic)=k then inc(r);

end;

if r=0 then

writeln(0)

else if r=t then

writeln(1)

else

begin

k:=cgb(r,t);

writeln(r div k,'/',t div k);

end;

end.

查看更多回复
提交回复