#include<stdio.h>
#define MOD 1000000007
int getRightValue(int *beforeRightValue, int depth);
int Factorial(int n);
int main(void){
int leftNodeCount[100];
int rightValue[100];
int input[100];
int result[100];
int depth;
scanf("%d", &depth);
for(int i=0; i<depth; i++){
scanf("%d", &input[i]);
}
leftNodeCount[0]=0;
rightValue[0]=0;
for(int i=1; i<=depth; i++){
rightValue[i]=getRightValue(&rightValue[i-1], i)%MOD;
leftNodeCount[i]=(leftNodeCount[i-1]*i+(input[i-1]-1))%MOD;
result[i-1]=(leftNodeCount[i]+rightValue[i-1]+1)%MOD;
}
for(int i=0; i<depth; i++){
printf("%d\n",result[i]);
}
return 0;
}
int Factorial(int n){
int result=1;
for(int i=1; i<=n; i++)
result=(result*i)%MOD;
return result;
}
int getRightValue(int *beforeRightValue, int depth){
return *beforeRightValue+Factorial(depth)%MOD;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |