# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4333 | zorrapower | Inherited disease (kriii1_I) | C++98 | 200 ms | 1088 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
}
while(true);
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |