Submission #3905

# Submission time Handle Problem Language Result Execution time Memory
3905 2013-08-31T09:16:12 Z jays Inherited disease (kriii1_I) C++
0 / 1
0 ms 1088 KB
#include <cstdio>

const int MOD = 1000000007;
int D, cid[101];
unsigned long long num[101];

void prep() {
	num[0] = 0;
	num[1] = 1;
	for (int i = 2; i <= 100; ++i) {
		num[i] = num[i-1];
		for (int j = 0; j < i; ++j)
			num[i] += (num[i-1] - num[i-2]) % MOD;
	}
}

void solve() {
	int priv = cid[1];
	for (int i = 2; i < D; ++i) {
		int cur = (i + 1) * (priv - 1) + priv - 1;
		printf("%lld\n", (num[i] + cur) % MOD);
		priv = cur;
	}
}

int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; ++i)
		scanf("%d", &cid[i]);
	prep();
	if (D == 1)
		printf("%d\n", cid[0]);
	else {
		printf("%d\n", cid[0]);
		printf("%d\n", cid[0]+cid[1]);
		if (D >= 3) solve();
	} 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1088 KB Output isn't correct
2 Halted 0 ms 0 KB -