#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 |
- |