Submission #3801

# Submission time Handle Problem Language Result Execution time Memory
3801 2013-08-31T08:25:34 Z zzapcoder Inherited disease (kriii1_I) C++
0 / 1
0 ms 1204 KB
#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
1 Correct 0 ms 1204 KB Output is correct
2 Incorrect 0 ms 1204 KB Output isn't correct
3 Halted 0 ms 0 KB -