QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#474367#2568. Mountainslichenyu_acWA 2ms3952kbC++141.2kb2024-07-12 17:40:242024-07-12 17:40:25

Judging History

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

  • [2024-07-12 17:40:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3952kb
  • [2024-07-12 17:40:24]
  • 提交

answer

#include<bits/stdc++.h>
#define x first
#define y second
typedef long long ll;
using namespace std;
const int N=110,mod=1e9+7;

ll power(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}

ll n,m,K;
ll A[N][N],f[N<<1],incf[N<<1];
void init(int n){
	f[0]=1;
	for(int i=1;i<=n;i++)f[i]=f[i-1]*i%mod;
	incf[n]=power(f[n],mod-2);
	for(int i=n-1;i>=0;i--)incf[i]=incf[i+1]*(i+1)%mod;
}

ll C(ll a,ll b){
	if(a<b)return 0;
	return f[a]*incf[b]%mod*incf[a-b]%mod;
}

ll Guess(){
	ll op=1,ans=1;
	for(int i=1;i<=K;i++){
		int pos=i;
		for(int j=i+1;j<=K;j++){
			if(A[j][i]>A[pos][i])pos=j;
		}
		if(i!=pos)op=-op,swap(A[i],A[pos]);
		if(!A[i][i])return 0;
		for(int j=1;j<=K;j++){
			if(i==j)continue;
			ll tmp=A[j][i]*power(A[i][i],mod-2)%mod;
			for(int k=1;k<=K;k++)
				A[j][k]=(A[j][k]-tmp*A[i][k]%mod+mod)%mod;
		}
		ans=ans*A[i][i]%mod;
		ll tmp=power(A[i][i],mod-2);
		for(int j=1;j<=K;j++)
			A[i][j]=A[i][j]*tmp%mod;
	}
	return (op*ans+mod)%mod;
}

int main(){
	init((N<<1)-1);
	scanf("%lld%lld%lld",&n,&m,&K);
	for(int i=1;i<=K;i++)
		for(int j=1;j<=K;j++){
			ll x=n+(j-i),y=m-(j-i);
			A[i][j]=C(x+y,x);
		}
	printf("%lld\n",Guess());
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

2 2 2

output:

20

result:

ok 1 number(s): "20"

Test #3:

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

input:

2 3 4

output:

490

result:

ok 1 number(s): "490"

Test #4:

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

input:

1 2 8

output:

45

result:

ok 1 number(s): "45"

Test #5:

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

input:

1 10 2

output:

66

result:

ok 1 number(s): "66"

Test #6:

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

input:

9 5 7

output:

371850968

result:

ok 1 number(s): "371850968"

Test #7:

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

input:

3 3 1

output:

20

result:

ok 1 number(s): "20"

Test #8:

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

input:

7 7 9

output:

166345303

result:

ok 1 number(s): "166345303"

Test #9:

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

input:

25 15 25

output:

850087558

result:

ok 1 number(s): "850087558"

Test #10:

score: -100
Wrong Answer
time: 2ms
memory: 3844kb

input:

45 59 71

output:

426274117

result:

wrong answer 1st numbers differ - expected: '659153227', found: '426274117'