QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88577 | #2573. Two Permutations | s8194272 | AC ✓ | 45ms | 5408kb | C++14 | 1.7kb | 2023-03-16 15:58:46 | 2023-03-16 15:58:47 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<random>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) ((x)&(-(x)))
#define fan(x) ((((x)-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define SZ(x) ((int)(x.size()))
#define INF 0x3f3f3f3f
using namespace std;
inline int read()
{
int ans=0,f=1;
char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
return ans*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x/10) write(x/10);
putchar((char)(x%10)+'0');
}
template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}
const int N=105,mod=1e9+7;
int n,k,f[N][N*N];
signed main()
{
n=read();k=read();
f[0][0]=1;
for(int i=0;i<n;++i)
{
for(int j=i;j>=0;--j)
for(int p=k;p>=0;--p)
if(f[j][p])
{
if(j+1<=i) f[j+2][p]=(f[j+2][p]+f[j][p]*1ll*(i-j)*(i-j))%mod;
if(p+n-i<=k&&n-2*i+j>0) f[j+1][p+n-i]=(f[j+1][p+n-i]+f[j][p]*1ll*((i-j)*2+1)*(n-2*i+j))%mod;
if(p+(n-i)*2<=k&&n-2*i+j-1>0) f[j][p+(n-i)*2]=(f[j][p+(n-i)*2]+f[j][p]*1ll*(n-2*i+j)*(n-2*i+j-1))%mod;
f[j][p]=0;
}
}
write(f[n][k]);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3284kb
input:
2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
3 7
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3296kb
input:
4 10
output:
24
result:
ok 1 number(s): "24"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3376kb
input:
4 14
output:
96
result:
ok 1 number(s): "96"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3412kb
input:
5 10
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
5 15
output:
120
result:
ok 1 number(s): "120"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
5 21
output:
2400
result:
ok 1 number(s): "2400"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3300kb
input:
6 21
output:
720
result:
ok 1 number(s): "720"
Test #9:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
6 30
output:
25920
result:
ok 1 number(s): "25920"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
6 27
output:
106560
result:
ok 1 number(s): "106560"
Test #11:
score: 0
Accepted
time: 2ms
memory: 3292kb
input:
20 300
output:
644873710
result:
ok 1 number(s): "644873710"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3236kb
input:
20 139
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3408kb
input:
30 470
output:
491424690
result:
ok 1 number(s): "491424690"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
30 500
output:
8436035
result:
ok 1 number(s): "8436035"
Test #15:
score: 0
Accepted
time: 2ms
memory: 3760kb
input:
40 1000
output:
617159088
result:
ok 1 number(s): "617159088"
Test #16:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
40 900
output:
729805907
result:
ok 1 number(s): "729805907"
Test #17:
score: 0
Accepted
time: 4ms
memory: 3712kb
input:
60 1830
output:
16340084
result:
ok 1 number(s): "16340084"
Test #18:
score: 0
Accepted
time: 6ms
memory: 3748kb
input:
60 2000
output:
832198921
result:
ok 1 number(s): "832198921"
Test #19:
score: 0
Accepted
time: 17ms
memory: 4424kb
input:
100 5050
output:
437918130
result:
ok 1 number(s): "437918130"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
100 700
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 45ms
memory: 5408kb
input:
100 10000
output:
0
result:
ok 1 number(s): "0"