#include <stdio.h>
#include <vector>
#define MMOD 1000000007
int D;
std::vector<int> C;
std::vector<int> M;
std::vector<long long> NC;
long long cchild(long long n)
{
long long result = 1;
for (long long i = 1; i <= n ; i++)
{
result = (result * i)%MMOD;
}
return result;
}
int main()
{
scanf("%d", &D);
for ( int i = 0 ; i < D ; i++)
{
int tmp;
scanf("%d", &tmp);
C.push_back(tmp);
}
long long LB = 0; // 이전 세대 마지막수;
long long CB = 1; // 이전에 몇번째 자식이었나..
long long Result = 0; // 출력에 쓰이는 수
for ( long long i = 1 ; i <= D; i++)
{
Result = (LB%MMOD + i*( (CB-1)%MMOD )%MMOD + C[i-1]%MMOD)%MMOD;
CB = ( i*( (CB-1)%MMOD )%MMOD+C[i-1]%MMOD)%MMOD;
LB = ( LB%MMOD + cchild(i)%MMOD ) % MMOD;
printf("%lld\n", Result);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1204 KB |
Output is correct |
2 |
Correct |
0 ms |
1204 KB |
Output is correct |
3 |
Correct |
0 ms |
1204 KB |
Output is correct |
4 |
Correct |
0 ms |
1204 KB |
Output is correct |
5 |
Correct |
0 ms |
1204 KB |
Output is correct |
6 |
Correct |
0 ms |
1204 KB |
Output is correct |
7 |
Correct |
0 ms |
1204 KB |
Output is correct |
8 |
Correct |
0 ms |
1204 KB |
Output is correct |
9 |
Correct |
0 ms |
1204 KB |
Output is correct |
10 |
Correct |
0 ms |
1204 KB |
Output is correct |
11 |
Correct |
0 ms |
1204 KB |
Output is correct |
12 |
Correct |
0 ms |
1204 KB |
Output is correct |
13 |
Correct |
0 ms |
1204 KB |
Output is correct |
14 |
Correct |
0 ms |
1204 KB |
Output is correct |
15 |
Correct |
0 ms |
1204 KB |
Output is correct |
16 |
Correct |
0 ms |
1204 KB |
Output is correct |
17 |
Correct |
0 ms |
1204 KB |
Output is correct |
18 |
Correct |
0 ms |
1204 KB |
Output is correct |
19 |
Correct |
0 ms |
1204 KB |
Output is correct |
20 |
Correct |
0 ms |
1204 KB |
Output is correct |