# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3684 | wurikiji | Inherited disease (kriii1_I) | C++98 | 0 ms | 1672 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 <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];
long long dap;
vector<int> ls;
void get_prev(int len, int target )
{
if( len == ls.size())
{
dap = (dap + target ) %divv;
return ;
}
for(int i = 0 ;i < ls[len];i++)
{
get_prev(len+1,target);
}
}
int main(void){
int d;
int k;
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);
scanf("%d", &k);
printf("1\n");
for(int i = 2 ;i <= d;i++)
{
scanf("%d", &k);
dap = sum[i-1];
if( ls.size() > 0 )
{
get_prev(0, i );
dap = (dap - i) %divv;
}
dap = (dap + k) %divv;
printf("%lld\n",dap);
ls.push_back(k);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |