Submission #4335

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