讨论 / f[1001][1001]与f[1002][1002]de悲剧
huhang1996 2013-11-08 08:05:40
点我顶贴 收藏 删除
#include<iostream>

#include<fstream>

#define ui 1000000007

using namespace std;

ifstream fin("ex1.txt");

long long f[1002][1002];

long long n,m,k;

long long shu(int x,int y)

{

long op;

op=(n+1-x)*(m+2-y)+(n+2-x)*(m+1-y);

return op;

}

long long gcd(long long a1,long long a2)

{

if(a2==0)

{return a1;}

else

{return gcd(a2,a1%a2);}

}

int main()

{

cin>>n>>m>>k;

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

f[i][1]=1;

for(int i=1;i<=m+1;i++)

f[1][i]=1;

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

for(int j=2;j<=m+1;j++)

f[i][j]=(f[i-1][j]+f[i][j-1])%ui;

/*

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

{

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

cout<<f[i][j]<<" ";

cout<<endl;

} */

//cout<<endl;

long long num;

long long tot=0;

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

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

{

if(i<n+1)//cout right

{

num=(f[n-i+1][m+2-j]*f[i][j])%ui;

// cout<<num<<" "<<i+1<<" "<<j<<endl;

if((f[n+1][m+1]>=num)&&((f[n+1][m+1]-num)==k))

{tot++;}

if((f[n+1][m+1]<num)&&((f[n+1][m+1]+ui-num)==k))

{tot++;}

}

if(j<m+1)//cout right

{

num=(f[n+2-i][m-j+1]*f[i][j])%ui;

// cout<<num<<" "<<i<<" "<<j+1<<endl;

if((f[n+1][m+1]>=num)&&((f[n+1][m+1]-num)==k))

{tot++;}

if((f[n+1][m+1]<num)&&((f[n+1][m+1]+ui-num)==k))

{tot++;}

}

}

long long gcd1;

long sum;

sum=n*(m+1)+m*(n+1);

if(tot==0)

{cout<<0;}

else if(tot==sum)

{cout<<1;}

else

{

gcd1=gcd(sum,tot);

cout<<(tot/gcd1)<<"/"<<(sum/gcd1);

}

//system("pause");

return 0;

}

导致最后一组满范围1000*1000没过WA90

查看更多回复
提交回复