답안 #717237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
717237 2023-04-01T16:00:51 Z fatemetmhr Asceticism (JOI18_asceticism) C++17
49 / 100
55 ms 39896 KB
// ~ Be Name Khoda ~

#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,O3")

using namespace std;

typedef long long ll;

#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second

const int maxn  =  3e3   + 10;
const int maxn5 =  3e3   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   +  7;
const ll  inf   =  1e18;

int ent[maxn][maxn], pw[maxn][maxn];
int f[maxn];

inline void fix(int &a){
    if(a < 0)
        a += mod;
    if(a >= mod)
        a -= mod;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, k; cin >> n >> k;
    if(n > 3000)
        return 0;
    ent[0][0] = 1;
    for(int i = 1; i < maxn; i++){
        ent[i][0] = 1;
        for(int j = 1; j <= i; j++)
            fix(ent[i][j] = ent[i - 1][j] + ent[i - 1][j - 1]);
    }
    for(ll i = 0; i <= n; i++){
        pw[i][0] = 1;
        for(int j = 1; j < maxn; j++)
            pw[i][j] = pw[i][j - 1] * i % mod;
    }

    for(int i = 1; i <= k; i++) for(int j = 1; j <= i; j++)
        fix(f[i] += (ll(ent[i][j]) * pw[j][n] % mod) * (i % 2 == j % 2 ? 1 : -1));
    int ans = 0;
    for(int i = 1; i <= k; i++){
        fix(ans += (ll(f[i]) * ent[n - i][k - i] % mod) * (i % 2 == k % 2 ? 1 : -1));
        //cout << i << ' ' << f[i] << endl;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 28092 KB Output is correct
2 Correct 30 ms 28132 KB Output is correct
3 Correct 30 ms 28108 KB Output is correct
4 Correct 30 ms 28096 KB Output is correct
5 Correct 31 ms 28152 KB Output is correct
6 Correct 31 ms 28108 KB Output is correct
7 Correct 32 ms 28068 KB Output is correct
8 Correct 31 ms 28060 KB Output is correct
9 Correct 30 ms 28124 KB Output is correct
10 Correct 31 ms 28036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 28092 KB Output is correct
2 Correct 30 ms 28132 KB Output is correct
3 Correct 30 ms 28108 KB Output is correct
4 Correct 30 ms 28096 KB Output is correct
5 Correct 31 ms 28152 KB Output is correct
6 Correct 31 ms 28108 KB Output is correct
7 Correct 32 ms 28068 KB Output is correct
8 Correct 31 ms 28060 KB Output is correct
9 Correct 30 ms 28124 KB Output is correct
10 Correct 31 ms 28036 KB Output is correct
11 Correct 36 ms 29236 KB Output is correct
12 Correct 36 ms 31552 KB Output is correct
13 Correct 36 ms 31608 KB Output is correct
14 Correct 36 ms 31564 KB Output is correct
15 Correct 37 ms 31556 KB Output is correct
16 Correct 38 ms 31564 KB Output is correct
17 Correct 36 ms 30412 KB Output is correct
18 Correct 40 ms 31036 KB Output is correct
19 Correct 32 ms 29560 KB Output is correct
20 Correct 31 ms 28108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 28092 KB Output is correct
2 Correct 30 ms 28132 KB Output is correct
3 Correct 30 ms 28108 KB Output is correct
4 Correct 30 ms 28096 KB Output is correct
5 Correct 31 ms 28152 KB Output is correct
6 Correct 31 ms 28108 KB Output is correct
7 Correct 32 ms 28068 KB Output is correct
8 Correct 31 ms 28060 KB Output is correct
9 Correct 30 ms 28124 KB Output is correct
10 Correct 31 ms 28036 KB Output is correct
11 Correct 36 ms 29236 KB Output is correct
12 Correct 36 ms 31552 KB Output is correct
13 Correct 36 ms 31608 KB Output is correct
14 Correct 36 ms 31564 KB Output is correct
15 Correct 37 ms 31556 KB Output is correct
16 Correct 38 ms 31564 KB Output is correct
17 Correct 36 ms 30412 KB Output is correct
18 Correct 40 ms 31036 KB Output is correct
19 Correct 32 ms 29560 KB Output is correct
20 Correct 31 ms 28108 KB Output is correct
21 Correct 55 ms 39808 KB Output is correct
22 Correct 50 ms 39872 KB Output is correct
23 Correct 53 ms 39848 KB Output is correct
24 Correct 50 ms 39832 KB Output is correct
25 Correct 50 ms 39896 KB Output is correct
26 Correct 52 ms 39824 KB Output is correct
27 Correct 52 ms 39756 KB Output is correct
28 Correct 44 ms 35148 KB Output is correct
29 Correct 40 ms 30384 KB Output is correct
30 Correct 50 ms 39760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 28092 KB Output is correct
2 Correct 30 ms 28132 KB Output is correct
3 Correct 30 ms 28108 KB Output is correct
4 Correct 30 ms 28096 KB Output is correct
5 Correct 31 ms 28152 KB Output is correct
6 Correct 31 ms 28108 KB Output is correct
7 Correct 32 ms 28068 KB Output is correct
8 Correct 31 ms 28060 KB Output is correct
9 Correct 30 ms 28124 KB Output is correct
10 Correct 31 ms 28036 KB Output is correct
11 Correct 36 ms 29236 KB Output is correct
12 Correct 36 ms 31552 KB Output is correct
13 Correct 36 ms 31608 KB Output is correct
14 Correct 36 ms 31564 KB Output is correct
15 Correct 37 ms 31556 KB Output is correct
16 Correct 38 ms 31564 KB Output is correct
17 Correct 36 ms 30412 KB Output is correct
18 Correct 40 ms 31036 KB Output is correct
19 Correct 32 ms 29560 KB Output is correct
20 Correct 31 ms 28108 KB Output is correct
21 Correct 55 ms 39808 KB Output is correct
22 Correct 50 ms 39872 KB Output is correct
23 Correct 53 ms 39848 KB Output is correct
24 Correct 50 ms 39832 KB Output is correct
25 Correct 50 ms 39896 KB Output is correct
26 Correct 52 ms 39824 KB Output is correct
27 Correct 52 ms 39756 KB Output is correct
28 Correct 44 ms 35148 KB Output is correct
29 Correct 40 ms 30384 KB Output is correct
30 Correct 50 ms 39760 KB Output is correct
31 Incorrect 0 ms 212 KB Output isn't correct
32 Halted 0 ms 0 KB -