Submission #19668

# Submission time Handle Problem Language Result Execution time Memory
19668 2016-02-25T04:24:09 Z xdoju 비트 (kriii4_Q) C++14
9 / 100
0 ms 1088 KB
#include <cstdio>
using namespace std;

const long long MOD = 1000000007ll;

long long modpow(long long r, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n % 2 > 0) {
			ret = (ret * r) % MOD;
		}
		r = (r * r) % MOD;
		n /= 2;
	}
	return ret;
}

long long modinv(long long n) {
	return modpow(n, MOD - 2);
}

long long coff[300], add[300];
long long ans[300];

void proc() {
	int n, k;
	scanf("%d %d", &n, &k);

	coff[1] = ((n - 1) * modinv(n)) % MOD;
	add[1] = 1;
	for (int i = 2; i < n; ++i) {
		long long t = (((coff[i - 1] * i) % MOD) * modinv(n)) % MOD;
		long long u = (1 - t + MOD) % MOD;

		long long v = ((n - i) * modinv(n)) % MOD;
		coff[i] = (v * modinv(u)) % MOD;

		long long w = (1 + ((((i * modinv(n)) % MOD) * add[i - 1]) % MOD)) % MOD;
		add[i] = (w * modinv(u)) % MOD;
	}

	ans[n] = ((add[n - 1] + 1) * modinv((1 - coff[n - 1] + MOD) % MOD)) % MOD;
	for (int i = n - 1; i >= 1; --i) {
		ans[i] = (((ans[i + 1] * coff[i]) % MOD) + add[i]) % MOD;
	}

	for (int i = 1; i <= n; ++i) {
		printf("%lld\n", ans[i]);
	}
}

int main() {
	proc();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Correct 0 ms 1088 KB Output is correct
3 Correct 0 ms 1088 KB Output is correct
4 Correct 0 ms 1088 KB Output is correct
5 Correct 0 ms 1088 KB Output is correct
6 Correct 0 ms 1088 KB Output is correct
7 Correct 0 ms 1088 KB Output is correct
8 Correct 0 ms 1088 KB Output is correct
9 Correct 0 ms 1088 KB Output is correct
10 Correct 0 ms 1088 KB Output is correct
11 Correct 0 ms 1088 KB Output is correct
12 Correct 0 ms 1088 KB Output is correct
13 Correct 0 ms 1088 KB Output is correct
14 Correct 0 ms 1088 KB Output is correct
15 Correct 0 ms 1088 KB Output is correct
16 Correct 0 ms 1088 KB Output is correct
17 Correct 0 ms 1088 KB Output is correct
18 Correct 0 ms 1088 KB Output is correct
19 Correct 0 ms 1088 KB Output is correct
20 Correct 0 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1088 KB Output isn't correct
2 Halted 0 ms 0 KB -