Submission #361740

#TimeUsernameProblemLanguageResultExecution timeMemory
361740dolphingarlicAsceticism (JOI18_asceticism)C++14
100 / 100
24 ms492 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

ll expo(ll b, ll p) {
	ll ans = 1;
	while (p) {
		if (p & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		p >>= 1;
	}
	return ans;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	ll ans = 0, c = 1, d = 1;
	for (int i = 0; i <= k; i++) {
		ans = (ans + d * c % MOD * expo(k - i, n)) % MOD;
		c = c * (n + 1 - i) % MOD * expo(i + 1, MOD - 2) % MOD;
		d = MOD - d;
	}
	printf("%lld", ans);
	return 0;
}

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...