Submission #4333

#TimeUsernameProblemLanguageResultExecution timeMemory
4333zorrapowerInherited disease (kriii1_I)C++98
0 / 1
200 ms1088 KiB
#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 timeMemoryGrader output
Fetching results...