#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238
double circumference(double r)
{
double cir = 2.0;
cir*=PI;
cir*=r;
return cir;
}
ll m;
long long binpow(long long a, long long b) {
a%=MOD;
long long res = 1;
while (b > 0) {
if (b & 1)
res = (res * a)%MOD;
a = (a * a)%MOD;
b >>= 1;
}
res%=MOD;
return res;
}
ll t[3005][3005];
void solve(){
ll n,k;
cin>>n>>k;
t[1][1] = 1;
// for(int i =0;i<=n;i++){
// for(int j =0;j<=n;j++){
// t[i][j] = 1;
// }
// }
for(ll i =1;i<=n;i++){
for(ll j = 1;j<=i;j++){
if(i==1&&j==1)continue;
ll xd = t[i-1][j]%MOD;
xd = (xd * j)%MOD;
if(xd < 0) xd += MOD;
t[i][j] = (t[i][j] + xd)%MOD;
if(t[i][j]<0)t[i][j]+=MOD;
//(i-j+1) * t[i-1][j-1]
xd = (i-j+1);
xd = (xd * t[i-1][j-1])%MOD;
t[i][j] = (t[i][j] + xd)%MOD;
if(t[i][j]<0)t[i][j]+=MOD;
}
}
// for(int i =1;i<=n;i++){
// for(int j =1;j<=n;j++){
// cout<<t[i][j]<<" ";
// }
// cout<<endl;
// }
cout<<t[n][k]<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
ll t=1;
while(t--){
solve();
}
return 0;
}//42364286 418930126
// (3,2)
// (0,0) -> (-1,0) -> (-1,2) -> (3,2)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
768 KB |
Output is correct |
12 |
Correct |
6 ms |
1920 KB |
Output is correct |
13 |
Correct |
7 ms |
1920 KB |
Output is correct |
14 |
Correct |
6 ms |
1920 KB |
Output is correct |
15 |
Correct |
6 ms |
1920 KB |
Output is correct |
16 |
Correct |
6 ms |
1920 KB |
Output is correct |
17 |
Correct |
6 ms |
1280 KB |
Output is correct |
18 |
Correct |
6 ms |
1664 KB |
Output is correct |
19 |
Correct |
5 ms |
896 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
768 KB |
Output is correct |
12 |
Correct |
6 ms |
1920 KB |
Output is correct |
13 |
Correct |
7 ms |
1920 KB |
Output is correct |
14 |
Correct |
6 ms |
1920 KB |
Output is correct |
15 |
Correct |
6 ms |
1920 KB |
Output is correct |
16 |
Correct |
6 ms |
1920 KB |
Output is correct |
17 |
Correct |
6 ms |
1280 KB |
Output is correct |
18 |
Correct |
6 ms |
1664 KB |
Output is correct |
19 |
Correct |
5 ms |
896 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
18 ms |
8320 KB |
Output is correct |
22 |
Correct |
16 ms |
8320 KB |
Output is correct |
23 |
Correct |
16 ms |
8320 KB |
Output is correct |
24 |
Correct |
15 ms |
8320 KB |
Output is correct |
25 |
Correct |
15 ms |
8320 KB |
Output is correct |
26 |
Correct |
16 ms |
8320 KB |
Output is correct |
27 |
Correct |
17 ms |
8320 KB |
Output is correct |
28 |
Correct |
9 ms |
4224 KB |
Output is correct |
29 |
Correct |
6 ms |
1280 KB |
Output is correct |
30 |
Correct |
16 ms |
8192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
768 KB |
Output is correct |
12 |
Correct |
6 ms |
1920 KB |
Output is correct |
13 |
Correct |
7 ms |
1920 KB |
Output is correct |
14 |
Correct |
6 ms |
1920 KB |
Output is correct |
15 |
Correct |
6 ms |
1920 KB |
Output is correct |
16 |
Correct |
6 ms |
1920 KB |
Output is correct |
17 |
Correct |
6 ms |
1280 KB |
Output is correct |
18 |
Correct |
6 ms |
1664 KB |
Output is correct |
19 |
Correct |
5 ms |
896 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
18 ms |
8320 KB |
Output is correct |
22 |
Correct |
16 ms |
8320 KB |
Output is correct |
23 |
Correct |
16 ms |
8320 KB |
Output is correct |
24 |
Correct |
15 ms |
8320 KB |
Output is correct |
25 |
Correct |
15 ms |
8320 KB |
Output is correct |
26 |
Correct |
16 ms |
8320 KB |
Output is correct |
27 |
Correct |
17 ms |
8320 KB |
Output is correct |
28 |
Correct |
9 ms |
4224 KB |
Output is correct |
29 |
Correct |
6 ms |
1280 KB |
Output is correct |
30 |
Correct |
16 ms |
8192 KB |
Output is correct |
31 |
Runtime error |
166 ms |
94456 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |