Submission #442287

# Submission time Handle Problem Language Result Execution time Memory
442287 2021-07-07T11:44:45 Z iANikzad Asceticism (JOI18_asceticism) C++14
0 / 100
6 ms 4172 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cerr<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 5e5 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;

int fact[maxn];

int pw(int a,int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1) res = res * a % mod;
        a = a*a % mod;
        b/= 2;
    }

    return res;
}

int C(int n,int r) { return fact[n] * (pw(fact[r] * fact[n - r] % mod, mod-2)) % mod;  }

int32_t main()
{
    FAST;

    fact[0] = 1;
    for(int i = 1; i < maxn; i++) fact[i] = fact[i - 1] * i % mod;

    int n = 3, k = 2;

    int ans = 0;
    for(int i = 0; i <= k - 1; i++)
        for(int j = 0; j <= k - i - 1; j++)
        {
            int res = (pw(k - i - j, n) * C(n - k + j, j) % mod * C(k - j, i) % mod);
            if((i + j) % 2 == 1) res *= -1;

            ans = (ans + res)  %mod;
        }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4172 KB Output isn't correct
2 Halted 0 ms 0 KB -