Submission #3656

# Submission time Handle Problem Language Result Execution time Memory
3656 2013-08-31T07:22:23 Z wurikiji Inherited disease (kriii1_I) C++
0 / 1
0 ms 1672 KB
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

const long long divv = 1000000007;

long long child[101];
long long sum[101];

vector<int> ls;
int main(void){
	int d;

	int prev=0;

	child[0] = 0;
	sum[0] = 0;
	child[1] = 1;
	sum[1] = 1;
	for(int i = 2;i < 101;i++)
	{
		child[i] = (child[i-1] * i) % divv ;
		sum[i] = (sum[i-1] + child[i]) %divv;
	}

	ls.clear();

	scanf("%d",&d);
	for(int i = 1 ;i <= d;i++)
	{
		int k;
		scanf("%d", &k);
		long long dap = sum[i-1];

		long long prev = 1;
		for(int j = 0 ;j < ls.size();j++)
		{
			prev = (prev * ls[j]) % divv;
		}
		dap = (dap + (( prev-1 ) * i)%divv)%divv;

		dap = (dap + k) %divv;
		printf("%lld\n",dap);
		ls.push_back(k);
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -