답안 #128157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128157 2019-07-10T13:18:15 Z RockyB Asceticism (JOI18_asceticism) C++17
49 / 100
179 ms 35960 KB
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

#define rep(a, b, c) for (int a = (b); (a) <= (c); ++a)
#define per(a, b, c) for (int a = (b); (a) >= (c); --a) 

#define nl '\n'
#define ioi exit(0);

using namespace std;

typedef long long ll;

const int MAX_N = (int)3e3 + 7;
const int mod = (int)1e9 + 7;


int n, k;
int dp[MAX_N][MAX_N];
int calc(int v = 2, int cnt = 1) {
  if (v > n) return cnt == k;
  if (~dp[v][cnt]) return dp[v][cnt];
  return dp[v][cnt] = ((calc(v + 1, cnt) * 1ll * cnt % mod) + (calc(v + 1, cnt + 1) * 1ll * (v - cnt) % mod)) % mod;
}
int main() {
  #ifdef IOI
    freopen ("in.txt", "r", stdin);
  #endif
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  cout << calc();
  ioi
}
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35704 KB Output is correct
2 Correct 32 ms 35644 KB Output is correct
3 Correct 32 ms 35704 KB Output is correct
4 Correct 32 ms 35704 KB Output is correct
5 Correct 32 ms 35704 KB Output is correct
6 Correct 32 ms 35704 KB Output is correct
7 Correct 32 ms 35704 KB Output is correct
8 Correct 32 ms 35836 KB Output is correct
9 Correct 32 ms 35704 KB Output is correct
10 Correct 32 ms 35704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35704 KB Output is correct
2 Correct 32 ms 35644 KB Output is correct
3 Correct 32 ms 35704 KB Output is correct
4 Correct 32 ms 35704 KB Output is correct
5 Correct 32 ms 35704 KB Output is correct
6 Correct 32 ms 35704 KB Output is correct
7 Correct 32 ms 35704 KB Output is correct
8 Correct 32 ms 35836 KB Output is correct
9 Correct 32 ms 35704 KB Output is correct
10 Correct 32 ms 35704 KB Output is correct
11 Correct 31 ms 35704 KB Output is correct
12 Correct 33 ms 35676 KB Output is correct
13 Correct 34 ms 35684 KB Output is correct
14 Correct 33 ms 35832 KB Output is correct
15 Correct 33 ms 35704 KB Output is correct
16 Correct 33 ms 35704 KB Output is correct
17 Correct 33 ms 35808 KB Output is correct
18 Correct 33 ms 35704 KB Output is correct
19 Correct 32 ms 35736 KB Output is correct
20 Correct 32 ms 35704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35704 KB Output is correct
2 Correct 32 ms 35644 KB Output is correct
3 Correct 32 ms 35704 KB Output is correct
4 Correct 32 ms 35704 KB Output is correct
5 Correct 32 ms 35704 KB Output is correct
6 Correct 32 ms 35704 KB Output is correct
7 Correct 32 ms 35704 KB Output is correct
8 Correct 32 ms 35836 KB Output is correct
9 Correct 32 ms 35704 KB Output is correct
10 Correct 32 ms 35704 KB Output is correct
11 Correct 31 ms 35704 KB Output is correct
12 Correct 33 ms 35676 KB Output is correct
13 Correct 34 ms 35684 KB Output is correct
14 Correct 33 ms 35832 KB Output is correct
15 Correct 33 ms 35704 KB Output is correct
16 Correct 33 ms 35704 KB Output is correct
17 Correct 33 ms 35808 KB Output is correct
18 Correct 33 ms 35704 KB Output is correct
19 Correct 32 ms 35736 KB Output is correct
20 Correct 32 ms 35704 KB Output is correct
21 Correct 44 ms 35832 KB Output is correct
22 Correct 44 ms 35704 KB Output is correct
23 Correct 44 ms 35704 KB Output is correct
24 Correct 43 ms 35832 KB Output is correct
25 Correct 43 ms 35832 KB Output is correct
26 Correct 44 ms 35832 KB Output is correct
27 Correct 43 ms 35804 KB Output is correct
28 Correct 37 ms 35704 KB Output is correct
29 Correct 33 ms 35704 KB Output is correct
30 Correct 49 ms 35832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35704 KB Output is correct
2 Correct 32 ms 35644 KB Output is correct
3 Correct 32 ms 35704 KB Output is correct
4 Correct 32 ms 35704 KB Output is correct
5 Correct 32 ms 35704 KB Output is correct
6 Correct 32 ms 35704 KB Output is correct
7 Correct 32 ms 35704 KB Output is correct
8 Correct 32 ms 35836 KB Output is correct
9 Correct 32 ms 35704 KB Output is correct
10 Correct 32 ms 35704 KB Output is correct
11 Correct 31 ms 35704 KB Output is correct
12 Correct 33 ms 35676 KB Output is correct
13 Correct 34 ms 35684 KB Output is correct
14 Correct 33 ms 35832 KB Output is correct
15 Correct 33 ms 35704 KB Output is correct
16 Correct 33 ms 35704 KB Output is correct
17 Correct 33 ms 35808 KB Output is correct
18 Correct 33 ms 35704 KB Output is correct
19 Correct 32 ms 35736 KB Output is correct
20 Correct 32 ms 35704 KB Output is correct
21 Correct 44 ms 35832 KB Output is correct
22 Correct 44 ms 35704 KB Output is correct
23 Correct 44 ms 35704 KB Output is correct
24 Correct 43 ms 35832 KB Output is correct
25 Correct 43 ms 35832 KB Output is correct
26 Correct 44 ms 35832 KB Output is correct
27 Correct 43 ms 35804 KB Output is correct
28 Correct 37 ms 35704 KB Output is correct
29 Correct 33 ms 35704 KB Output is correct
30 Correct 49 ms 35832 KB Output is correct
31 Incorrect 179 ms 35960 KB Output isn't correct
32 Halted 0 ms 0 KB -