QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50489#2568. MountainsxiaoyaowudiAC ✓1ms2024kbC++171.0kb2022-09-26 19:14:212022-09-26 19:14:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-26 19:14:22]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:2024kb
  • [2022-09-26 19:14:21]
  • 提交

answer

#include <cstdio>
#include <algorithm>
using namespace std;
constexpr int N=110,p=1e9+7;
int fp(int a,int b){int ans=1,off=a;while(b){if(b&1) ans=1ll*ans*off%p;off=1ll*off*off%p;b>>=1;}return ans;}
int det[N][N],fac[N<<1],ifac[N<<1];
int calc(int a,int b){
	if(a<0 || b<0) return 0;
	return 1ll*fac[a+b]*ifac[a]%p*ifac[b]%p;
}
int main(){
	fac[0]=1;
	for(int i=1;i<(N<<1);++i) fac[i]=1ll*fac[i-1]*i%p;
	ifac[(N<<1)-1]=fp(fac[(N<<1)-1],p-2);
	for(int i=(N<<1)-2;i>=0;--i) ifac[i]=1ll*ifac[i+1]*(i+1)%p;
	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;++i){
		for(int j=1;j<=k;++j){
			det[i][j]=calc(n+i-j,m+j-i);
		}
	}
	int ans=1;
	for(int i=1;i<=k;++i){
		int pos=0;
		for(int j=i;j<=k;++j) if(det[j][i]) pos=j;
		if(!pos){ans=0;break;}
		if(pos!=i) swap(det[pos],det[i]),ans=p-ans;
		int num=p-fp(det[i][i],p-2);
		for(int j=i+1;j<=k;++j){
			int cur=1ll*num*det[j][i]%p;
			for(int t=i;t<=k;++t) det[j][t]=(det[j][t]+1ll*cur*det[i][t])%p;
		}
	}
	for(int i=1;i<=k;++i) ans=1ll*ans*det[i][i]%p;
	printf("%d\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 1768kb

input:

1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 1776kb

input:

2 2 2

output:

20

result:

ok 1 number(s): "20"

Test #3:

score: 0
Accepted
time: 1ms
memory: 2024kb

input:

2 3 4

output:

490

result:

ok 1 number(s): "490"

Test #4:

score: 0
Accepted
time: 1ms
memory: 1808kb

input:

1 2 8

output:

45

result:

ok 1 number(s): "45"

Test #5:

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

input:

1 10 2

output:

66

result:

ok 1 number(s): "66"

Test #6:

score: 0
Accepted
time: 1ms
memory: 1764kb

input:

9 5 7

output:

371850968

result:

ok 1 number(s): "371850968"

Test #7:

score: 0
Accepted
time: 1ms
memory: 1840kb

input:

3 3 1

output:

20

result:

ok 1 number(s): "20"

Test #8:

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

input:

7 7 9

output:

166345303

result:

ok 1 number(s): "166345303"

Test #9:

score: 0
Accepted
time: 1ms
memory: 1788kb

input:

25 15 25

output:

850087558

result:

ok 1 number(s): "850087558"

Test #10:

score: 0
Accepted
time: 1ms
memory: 1848kb

input:

45 59 71

output:

659153227

result:

ok 1 number(s): "659153227"

Test #11:

score: 0
Accepted
time: 1ms
memory: 1848kb

input:

73 3 25

output:

683124269

result:

ok 1 number(s): "683124269"

Test #12:

score: 0
Accepted
time: 1ms
memory: 1780kb

input:

1 48 78

output:

446896916

result:

ok 1 number(s): "446896916"

Test #13:

score: 0
Accepted
time: 1ms
memory: 1768kb

input:

25 100 32

output:

966287506

result:

ok 1 number(s): "966287506"

Test #14:

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

input:

85 64 40

output:

125679545

result:

ok 1 number(s): "125679545"

Test #15:

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

input:

5 9 94

output:

620471576

result:

ok 1 number(s): "620471576"

Test #16:

score: 0
Accepted
time: 1ms
memory: 1980kb

input:

33 57 40

output:

637315057

result:

ok 1 number(s): "637315057"

Test #17:

score: 0
Accepted
time: 1ms
memory: 1772kb

input:

61 6 97

output:

362472796

result:

ok 1 number(s): "362472796"

Test #18:

score: 0
Accepted
time: 1ms
memory: 1844kb

input:

85 50 51

output:

192099209

result:

ok 1 number(s): "192099209"

Test #19:

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

input:

96 54 59

output:

714762612

result:

ok 1 number(s): "714762612"

Test #20:

score: 0
Accepted
time: 1ms
memory: 1844kb

input:

20 99 12

output:

772155662

result:

ok 1 number(s): "772155662"

Test #21:

score: 0
Accepted
time: 1ms
memory: 1984kb

input:

48 39 62

output:

670046604

result:

ok 1 number(s): "670046604"

Test #22:

score: 0
Accepted
time: 1ms
memory: 1776kb

input:

76 83 16

output:

976820079

result:

ok 1 number(s): "976820079"

Test #23:

score: 0
Accepted
time: 1ms
memory: 1840kb

input:

96 36 61

output:

20854557

result:

ok 1 number(s): "20854557"

Test #24:

score: 0
Accepted
time: 1ms
memory: 1772kb

input:

18 40 77

output:

261684871

result:

ok 1 number(s): "261684871"

Test #25:

score: 0
Accepted
time: 1ms
memory: 1820kb

input:

42 84 26

output:

458573307

result:

ok 1 number(s): "458573307"

Test #26:

score: 0
Accepted
time: 1ms
memory: 1784kb

input:

71 25 80

output:

875902815

result:

ok 1 number(s): "875902815"

Test #27:

score: 0
Accepted
time: 1ms
memory: 1724kb

input:

95 73 26

output:

922299967

result:

ok 1 number(s): "922299967"

Test #28:

score: 0
Accepted
time: 1ms
memory: 1820kb

input:

19 17 83

output:

494148696

result:

ok 1 number(s): "494148696"

Test #29:

score: 0
Accepted
time: 1ms
memory: 1876kb

input:

100 100 100

output:

192912055

result:

ok 1 number(s): "192912055"

Test #30:

score: 0
Accepted
time: 1ms
memory: 1772kb

input:

100 98 99

output:

412293529

result:

ok 1 number(s): "412293529"