# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3801 | zzapcoder | Inherited disease (kriii1_I) | C++98 | 0 ms | 1204 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>
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |