QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#474159#2568. Mountainsyqh2025WA 0ms4136kbC++141.5kb2024-07-12 16:25:392024-07-12 16:25:40

Judging History

你现在查看的是最新测评结果

  • [2024-07-12 16:25:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4136kb
  • [2024-07-12 16:25:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=110,mod=1e9+7;
int ksm(int x,int y){int ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}
int inv(int x){return ksm(x,mod-2);}
struct matrix{
	int s[N][N],n,m;
	int* operator [](int x){return s[x];}
	matrix(){memset(s,0,sizeof(s));n=m=0;}
};
int dat(matrix x){
	int n=x.n,fl=1;
	for(int i=1;i<=n;i++){
		if(!x[i][i]){
			for(int j=i+1;j<=n;j++){
				if(x[j][i]){
					fl*=-1;for(int k=1;k<=n;k++)swap(x[i][k],x[j][k]);
					break;
				}
			}
		}
		if(!x[i][i])return 0;
		for(int j=i+1;j<=n;j++){
			if(x[j][i]>x[i][i]){
				fl*=-1;for(int k=1;k<=n;k++)swap(x[i][k],x[j][k]);
			}
			while(x[j][i]){
				int S=x[i][i]/x[j][i];
				for(int k=i;k<=n;k++)x[i][k]=(x[i][k]-S*x[j][k]);
				fl*=-1;for(int k=1;k<=n;k++)swap(x[i][k],x[j][k]);
			}
			// for(int k=1;k<=n;k++)x[j][k]%=mod;
		}
	}
	int ans=(fl+mod)%mod;
	for(int i=1;i<=n;i++)ans=ans*(x[i][i]+mod)%mod;
	return ans;
}
int n,m,k;
int jc[N<<1],invjc[N<<1];
void init(){
	int u=n+m;
	jc[0]=1;for(int i=1;i<=u;i++)jc[i]=jc[i-1]*i%mod;
	invjc[u]=inv(jc[u]);
	for(int i=u-1;i>=0;i--)invjc[i]=invjc[i+1]*(i+1)%mod;
}
int C(int n,int m){
	if(n<m)return 0;
	return jc[n]*invjc[m]%mod*invjc[n-m]%mod;
}
signed main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	init();
	matrix A;A.n=A.m=k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			int x=n+(j-i),y=m-(j-i);
			A[i][j]=C(x+y,x);
		}
	}
	printf("%lld",dat(A));
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4060kb

input:

1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

2 2 2

output:

20

result:

ok 1 number(s): "20"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

2 3 4

output:

490

result:

ok 1 number(s): "490"

Test #4:

score: 0
Accepted
time: 0ms
memory: 4056kb

input:

1 2 8

output:

45

result:

ok 1 number(s): "45"

Test #5:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

1 10 2

output:

66

result:

ok 1 number(s): "66"

Test #6:

score: 0
Accepted
time: 0ms
memory: 4132kb

input:

9 5 7

output:

371850968

result:

ok 1 number(s): "371850968"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

3 3 1

output:

20

result:

ok 1 number(s): "20"

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 4136kb

input:

7 7 9

output:

580093176

result:

wrong answer 1st numbers differ - expected: '166345303', found: '580093176'