Submission #4202

# Submission time Handle Problem Language Result Execution time Memory
4202 2013-09-05T04:16:07 Z pl0892029 Inherited disease (kriii1_I) C++
0 / 1
0 ms 1088 KB
#include <stdio.h>

int main() {
	int c, tmp=1;
	long long num=0, p[100];
	int mod = 1000000007;
	scanf("%d", &c);
	for(int i=0;i<c;i++) {
		scanf("%d", &p[i]);
	}

	for(int i=0;i<c;i++) {
		if(i>0) {
			num=(num+p[i]+((i+1)*(mod+p[i-1]-1))+(tmp+mod-p[i-1]))%mod;
			p[i]=(p[i]+(p[i-1]-1)*(i+1))%mod;
			tmp=(tmp*(i+1))%mod;
		}
		else
			num=(num+p[i])%mod;
		printf("%lld\n", num%mod);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Incorrect 0 ms 1088 KB Output isn't correct
3 Halted 0 ms 0 KB -