# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
859498 |
2023-10-10T08:56:58 Z |
lucri |
NoM (RMI21_nom) |
C++17 |
|
500 ms |
6556 KB |
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long n,m,d[2010][2010],r[2010],fact[4010],ans;
void factorial()
{
fact[0]=1;
for(int i=1;i<=4000;++i)
fact[i]=(fact[i-1]*i)%MOD;
}
long long putere(long long a,long long b)
{
if(b==0)
return 1;
long long m=putere(a,b/2);
m*=m;
m%=MOD;
if(b%2)
{
m*=a;
m%=MOD;
}
return m;
}
long long combinari(long long n,long long m)
{
long long ans=fact[n];
ans*=putere(fact[m],MOD-2);
ans%=MOD;
ans*=putere(fact[n-m],MOD-2);
ans%=MOD;
return ans;
}
long long aranjamente(long long n,long long m)
{
long long ans=fact[n];
ans*=putere(fact[n-m],MOD-2);
ans%=MOD;
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
factorial();
cin>>n>>m;
d[0][0]=1;
for(int i=1;i<=2*n;++i)
++r[i%m];
r[m]=r[0];
for(int j=0;j<=n;++j)
for(int i=1;i<=m;++i)
for(int k=0;2*k<=r[i]&&k<=j;++k)
{
d[i][j]+=combinari(j,k)*aranjamente(r[i],2*k)%MOD*d[i-1][j-k]%MOD;
if(d[i][j]>=MOD)
d[i][j]-=MOD;
}
for(int i=1;i<=n;++i)
{
ans+=((i-1)%2*2-1)*d[m][i]%MOD*fact[2*n-2*i]%MOD*combinari(n,i)%MOD;
if(ans>=MOD)
ans-=MOD;
if(ans<0)
ans+=MOD;
}
ans+=fact[2*n];
if(ans>=MOD)
ans-=MOD;
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
496 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
496 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
732 KB |
Output is correct |
13 |
Correct |
3 ms |
348 KB |
Output is correct |
14 |
Correct |
4 ms |
856 KB |
Output is correct |
15 |
Correct |
6 ms |
768 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
496 KB |
Output is correct |
19 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
496 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
732 KB |
Output is correct |
13 |
Correct |
3 ms |
348 KB |
Output is correct |
14 |
Correct |
4 ms |
856 KB |
Output is correct |
15 |
Correct |
6 ms |
768 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
496 KB |
Output is correct |
19 |
Correct |
4 ms |
348 KB |
Output is correct |
20 |
Correct |
17 ms |
604 KB |
Output is correct |
21 |
Correct |
20 ms |
856 KB |
Output is correct |
22 |
Correct |
79 ms |
1932 KB |
Output is correct |
23 |
Correct |
36 ms |
620 KB |
Output is correct |
24 |
Correct |
72 ms |
1364 KB |
Output is correct |
25 |
Correct |
74 ms |
1892 KB |
Output is correct |
26 |
Correct |
39 ms |
348 KB |
Output is correct |
27 |
Correct |
104 ms |
2284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
496 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
732 KB |
Output is correct |
13 |
Correct |
3 ms |
348 KB |
Output is correct |
14 |
Correct |
4 ms |
856 KB |
Output is correct |
15 |
Correct |
6 ms |
768 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
496 KB |
Output is correct |
19 |
Correct |
4 ms |
348 KB |
Output is correct |
20 |
Correct |
17 ms |
604 KB |
Output is correct |
21 |
Correct |
20 ms |
856 KB |
Output is correct |
22 |
Correct |
79 ms |
1932 KB |
Output is correct |
23 |
Correct |
36 ms |
620 KB |
Output is correct |
24 |
Correct |
72 ms |
1364 KB |
Output is correct |
25 |
Correct |
74 ms |
1892 KB |
Output is correct |
26 |
Correct |
39 ms |
348 KB |
Output is correct |
27 |
Correct |
104 ms |
2284 KB |
Output is correct |
28 |
Correct |
221 ms |
1104 KB |
Output is correct |
29 |
Correct |
366 ms |
3316 KB |
Output is correct |
30 |
Correct |
438 ms |
5916 KB |
Output is correct |
31 |
Correct |
226 ms |
596 KB |
Output is correct |
32 |
Correct |
404 ms |
3704 KB |
Output is correct |
33 |
Execution timed out |
529 ms |
6556 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
496 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
732 KB |
Output is correct |
13 |
Correct |
3 ms |
348 KB |
Output is correct |
14 |
Correct |
4 ms |
856 KB |
Output is correct |
15 |
Correct |
6 ms |
768 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
604 KB |
Output is correct |
18 |
Correct |
4 ms |
496 KB |
Output is correct |
19 |
Correct |
4 ms |
348 KB |
Output is correct |
20 |
Correct |
17 ms |
604 KB |
Output is correct |
21 |
Correct |
20 ms |
856 KB |
Output is correct |
22 |
Correct |
79 ms |
1932 KB |
Output is correct |
23 |
Correct |
36 ms |
620 KB |
Output is correct |
24 |
Correct |
72 ms |
1364 KB |
Output is correct |
25 |
Correct |
74 ms |
1892 KB |
Output is correct |
26 |
Correct |
39 ms |
348 KB |
Output is correct |
27 |
Correct |
104 ms |
2284 KB |
Output is correct |
28 |
Correct |
221 ms |
1104 KB |
Output is correct |
29 |
Correct |
366 ms |
3316 KB |
Output is correct |
30 |
Correct |
438 ms |
5916 KB |
Output is correct |
31 |
Correct |
226 ms |
596 KB |
Output is correct |
32 |
Correct |
404 ms |
3704 KB |
Output is correct |
33 |
Execution timed out |
529 ms |
6556 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |