QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773873 | #2573. Two Permutations | xiezihan2023 | AC ✓ | 311ms | 231604kb | C++14 | 1.1kb | 2024-11-23 10:39:58 | 2024-11-23 10:39:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
long long ans;
long long mod=1e9+7;
int n,k2;
long long f[105][105][10505];
int main()
{
// freopen("cargo.in","r",stdin);
// freopen("cargo.out","w",stdout);
scanf("%d%d",&n,&k2);
f[0][0][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<i;j++)
{
for(int k=0;k<=min(k2,i*(i-1));k++)
{
long long num=1ll*(i-1-j);
// cout<<num<<endl;
// cout<<f[i-1][j][k]<<endl;
f[i][j+1][k+i]+=f[i-1][j][k]*1ll*(n-j-2*num);
f[i][j+1][k+i]%=mod;
// cout<<f[i-1][j][k]<<" "<<n<<" "<<2*num<<endl;
f[i][j][k]+=f[i-1][j][k]*1ll*(n-j-2*num)*(n-j-2*num-1);
f[i][j][k]%=mod;
f[i][j+2][k+2*i]+=f[i-1][j][k]*1ll*num*num;
f[i][j+2][k+2*i]%=mod;
f[i][j+1][k+i]+=f[i-1][j][k]*1ll*2*num*(n-j-2*num);
f[i][j+1][k+i]%=mod;
}
}
}
printf("%lld",f[n][n][k2]);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
3 7
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
4 10
output:
24
result:
ok 1 number(s): "24"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
4 14
output:
96
result:
ok 1 number(s): "96"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
5 10
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
5 15
output:
120
result:
ok 1 number(s): "120"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
5 21
output:
2400
result:
ok 1 number(s): "2400"
Test #8:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
6 21
output:
720
result:
ok 1 number(s): "720"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
6 30
output:
25920
result:
ok 1 number(s): "25920"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
6 27
output:
106560
result:
ok 1 number(s): "106560"
Test #11:
score: 0
Accepted
time: 0ms
memory: 5232kb
input:
20 300
output:
644873710
result:
ok 1 number(s): "644873710"
Test #12:
score: 0
Accepted
time: 1ms
memory: 5116kb
input:
20 139
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 0ms
memory: 7436kb
input:
30 470
output:
491424690
result:
ok 1 number(s): "491424690"
Test #14:
score: 0
Accepted
time: 4ms
memory: 7564kb
input:
30 500
output:
8436035
result:
ok 1 number(s): "8436035"
Test #15:
score: 0
Accepted
time: 4ms
memory: 12252kb
input:
40 1000
output:
617159088
result:
ok 1 number(s): "617159088"
Test #16:
score: 0
Accepted
time: 3ms
memory: 12160kb
input:
40 900
output:
729805907
result:
ok 1 number(s): "729805907"
Test #17:
score: 0
Accepted
time: 28ms
memory: 33132kb
input:
60 1830
output:
16340084
result:
ok 1 number(s): "16340084"
Test #18:
score: 0
Accepted
time: 36ms
memory: 34228kb
input:
60 2000
output:
832198921
result:
ok 1 number(s): "832198921"
Test #19:
score: 0
Accepted
time: 247ms
memory: 182720kb
input:
100 5050
output:
437918130
result:
ok 1 number(s): "437918130"
Test #20:
score: 0
Accepted
time: 31ms
memory: 57632kb
input:
100 700
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 311ms
memory: 231604kb
input:
100 10000
output:
0
result:
ok 1 number(s): "0"