Submission #342366

# Submission time Handle Problem Language Result Execution time Memory
342366 2021-01-02T01:10:14 Z jovan_b Asceticism (JOI18_asceticism) C++17
0 / 100
32 ms 1132 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back

const int MOD = 1000000007;

int add(int a, int b){
    a += b;
    if(a >= MOD) a -= MOD;
    return a;
}

int mul(int a, int b){
    return (1LL*a*b)%MOD;
}

int pw(int a, int b){
    if(b == 0) return 1;
    int res = pw(a, b/2);
    res = mul(res, res);
    if(b%2) res = mul(res, a);
    return res;
}

int fak[100005];
int inv[100005];

int bin(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    int res = fak[n];
    res = mul(res, inv[k]);
    res = mul(res, inv[n-k]);
    return res;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    int res = 0;
    fak[0] = inv[0] = 1;
    for(int i=1; i<=100000; i++){
        fak[i] = mul(fak[i-1], i);
        inv[i] = pw(fak[i], MOD-2);
    }
    for(int k=0; k<=m+1; k++){
        int tr = pw(m+1-k, n);
        tr = mul(tr, bin(n+1, k));
        if(k%2) res = add(res, MOD-tr);
        else res = add(res, tr);
    }
    cout << res << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -