Submission #442289

# Submission time Handle Problem Language Result Execution time Memory
442289 2021-07-07T11:45:41 Z iANikzad Asceticism (JOI18_asceticism) C++14
4 / 100
9 ms 4232 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, k;
  	cin >> n >> k;

    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 Correct 6 ms 4232 KB Output is correct
2 Correct 6 ms 4172 KB Output is correct
3 Correct 7 ms 4172 KB Output is correct
4 Correct 6 ms 4224 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 7 ms 4200 KB Output is correct
8 Correct 6 ms 4224 KB Output is correct
9 Correct 6 ms 4196 KB Output is correct
10 Correct 7 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4232 KB Output is correct
2 Correct 6 ms 4172 KB Output is correct
3 Correct 7 ms 4172 KB Output is correct
4 Correct 6 ms 4224 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 7 ms 4200 KB Output is correct
8 Correct 6 ms 4224 KB Output is correct
9 Correct 6 ms 4196 KB Output is correct
10 Correct 7 ms 4172 KB Output is correct
11 Correct 6 ms 4172 KB Output is correct
12 Correct 6 ms 4200 KB Output is correct
13 Correct 6 ms 4172 KB Output is correct
14 Incorrect 9 ms 4172 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4232 KB Output is correct
2 Correct 6 ms 4172 KB Output is correct
3 Correct 7 ms 4172 KB Output is correct
4 Correct 6 ms 4224 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 7 ms 4200 KB Output is correct
8 Correct 6 ms 4224 KB Output is correct
9 Correct 6 ms 4196 KB Output is correct
10 Correct 7 ms 4172 KB Output is correct
11 Correct 6 ms 4172 KB Output is correct
12 Correct 6 ms 4200 KB Output is correct
13 Correct 6 ms 4172 KB Output is correct
14 Incorrect 9 ms 4172 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4232 KB Output is correct
2 Correct 6 ms 4172 KB Output is correct
3 Correct 7 ms 4172 KB Output is correct
4 Correct 6 ms 4224 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 7 ms 4200 KB Output is correct
8 Correct 6 ms 4224 KB Output is correct
9 Correct 6 ms 4196 KB Output is correct
10 Correct 7 ms 4172 KB Output is correct
11 Correct 6 ms 4172 KB Output is correct
12 Correct 6 ms 4200 KB Output is correct
13 Correct 6 ms 4172 KB Output is correct
14 Incorrect 9 ms 4172 KB Output isn't correct
15 Halted 0 ms 0 KB -