Submission #4205

#TimeUsernameProblemLanguageResultExecution timeMemory
4205HiddenInherited disease (kriii1_I)C++98
1 / 1
0 ms1088 KiB
#include <stdio.h> int main() { int c; long long p[100], num=0, tmp=1; int mod = 1000000007; scanf("%d", &c); for(int i=0;i<c;i++) { scanf("%lld", &p[i]); } for(int i=0;i<c;i++) { if(i>0) { num=(num+p[i]+((i+1)*(p[i-1]-1))+(tmp-p[i-1]))%mod; p[i]=(p[i]+((p[i-1]-1)*(i+1)))%mod; tmp=(tmp*(i+1))%mod; } else num=(num+p[i]); printf("%lld\n", num); } }
#Verdict Execution timeMemoryGrader output
Fetching results...