Submission #3518

# Submission time Handle Problem Language Result Execution time Memory
3518 2013-08-31T06:20:10 Z cki86201 Inherited disease (kriii1_I) C++
1 / 1
0 ms 1088 KB
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
using namespace std;

int n,inp[110];
long long dp[110][2],f[110]={0,1};
const int M = 1e9+7;

int main()
{
	scanf("%d",&n);
	int p,i;
	for(i=2;i<=n;i++){f[i]=i*f[i-1];f[i]%=M;}
	for(i=1;i<=n;i++)scanf("%d",inp+i);
	dp[0][1]=1;
	long long s=0;
	for(i=1;i<=n;i++){
		dp[i][1]=(dp[i-1][1]-1)*i+inp[i];
		dp[i][0]=dp[i][1]+s;
		dp[i][0]%=M;
		dp[i][1]%=M;
		s+=f[i];
		s%=M;
		printf("%d\n",dp[i][0]);
	}
	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