답안 #3993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3993 2013-08-31T09:53:56 Z sjw0687 Inherited disease (kriii1_I) C++
0 / 1
0 ms 1672 KB
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;

typedef long long llong;
const llong MOD = 1000000007;

llong fact[101];
llong sumFact[101];

llong minu(llong a, llong b)
{
	llong ret = a - b;
	while( ret < 0 )
		ret += MOD;
	return ret;
}

int main(void)
{
	int n;
	cin >> n;
	int child[101];
	for(int i=1; i<=n; i++)
		cin >> child[i];

	fact[0] = 1, sumFact[0] = 0;
	for(int i=1; i<=n; i++) {
		fact[i] = fact[i-1] * i % MOD;
		sumFact[i] = (sumFact[i-1] + fact[i]) % MOD;
	}

	cout << "1" << endl;
	llong preFirst = 1; llong preNum = 1; llong curNum;
	for(int d=2; d<=n; d++) {
		llong first = (sumFact[d-1] + 1) % MOD;
		//cout << "first: " << first << endl;
		curNum = ((minu(first, 1) + (minu(preNum, preFirst) * sumFact[d-1] % MOD)) % MOD + child[d]) % MOD;
		preFirst = first;
		preNum = curNum;
		cout << curNum << endl;
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -