Submission #3801

#TimeUsernameProblemLanguageResultExecution timeMemory
3801zzapcoderInherited disease (kriii1_I)C++98
0 / 1
0 ms1204 KiB
#include <stdio.h> #include <vector> #define MMOD 1000000007 int D; std::vector<int> C; std::vector<int> M; std::vector<long long> NC; long long cchild(long long n) { long long result = 1; for (long long i = 1; i <= n ; i++) { result = (result * i)%MMOD; } return result; } int main() { scanf("%d", &D); for ( int i = 0 ; i < D ; i++) { int tmp; scanf("%d", &tmp); C.push_back(tmp); } long long LB = 0; // 이전 세대 마지막수; long long CB = 1; // 이전에 몇번째 자식이었나.. long long Result = 0; // 출력에 쓰이는 수 for ( long long i = 1 ; i <= D; i++) { Result = LB%MMOD + i*( (CB-1)%MMOD )%MMOD + C[i-1]%MMOD; CB = i*( (CB-1)%MMOD )%MMOD+C[i-1]%MMOD; LB = ( LB%MMOD + cchild(i)%MMOD ) % MMOD; // printf("CChild : %lld\n", cchild(3)); printf("%d\n", Result); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...