Submission #114139

# Submission time Handle Problem Language Result Execution time Memory
114139 2019-05-30T14:18:57 Z Saboon Asceticism (JOI18_asceticism) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;

int fac[maxn], revfac[maxn];

ll power(ll a, ll b){
	if (b == 0)
		return 1;
	ll ret = power(a, b / 2);
	ret = 1ll * ret * ret % mod;
	if (b & 1)
		return ret * a % mod;
	return ret;
}

ll C(int n, int r){
	return 1ll * fac[n] * revfac[r] % mod * revfac[n - r] % mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	fac[0] = 1;
	for (int i = 1; i <= n + 1; i++)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	revfac[n + 1] = power(fac[n + 1], mod - 2);
	for (int i = n; i >= 0; i--)
		revfac[i] = 1ll * revfac[i + 1] * (i + 1) % mod;
	ll answer = 0;
	int sign = 1;
	for (int k = 0; k <= m; k++){
		ll t = 1ll * sign * C(n + 1, k) * power(m + 1 - k, n) % mod;
		answer = (answer + t + mod) % mod;
		sign *= -1;
	}
	cout << answer << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -