# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4335 | 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
long long getRightValue(long long *beforeRightValue, long long depth);
long long Factorial(long long n);
int main(void){
long long leftNodeCount[100];
long long rightValue[100];
long long input[100];
long long result[100];
long long depth;
scanf("%lld", &depth);
for(int i=0; i<depth; i++){
scanf("%lld", &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(long long i=0; i<depth; i++){
printf("%d\n",result[i]);
}
while(true);
return 0;
}
long long Factorial(long long n){
long long result=1;
for(long long i=1; i<=n; i++)
result=(result*i)%MOD;
return result;
}
long long getRightValue(long long *beforeRightValue, long long depth){
return *beforeRightValue+Factorial(depth)%MOD;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |