讨论 / C++代码 RP++
1165082064 2014-09-02 13:31:36
点我顶贴 收藏 删除
#include<cstdio>

#include<cstring>

#define mo 1000000007

using namespace std;

int i,j,k,l,m,n;

int x,y;

int t=0;

long long a[1002][1002];

int gcd(int x,int y){

if (y==0) return x;

else gcd(y,x%y);

}

int main(){

freopen("test.in","r",stdin);

freopen("test.out","w",stdout);

scanf("%d%d%d",&n,&m,&k);

memset(a,0,sizeof(a));

a[1][1]=1;

for (i=1;i<=n+1;i++)

for (j=1;j<=m+1;j++){

if (i==1 && j==1) a[i][j]=1;

else a[i][j]=(a[i-1][j]+a[i][j-1])%mo;

}

long long sum=a[n+1][m+1];

for (x=n+1;x>=1;x--)

for (y=m+1;y>=1;y--){

if (x+1<=n+1){

i=x+1;

j=y;

long long sum2=((sum-a[x][y]*a[n+2-i][m+2-j]%mo)+mo)%mo;

if (sum2==k) t++;

}

if (y+1<=m+1){

i=x;

j=y+1;

long long sum2=((sum-a[x][y]*a[n+2-i][m+2-j]%mo)+mo)%mo;

if (sum2==k) t++;

}

}

int s=m*(n+1)+n*(m+1);

if (t==s) printf("1");

else {

int gys=gcd(s,t);

printf("%d/%d",t/gys,s/gys);

}

}

查看更多回复
提交回复