# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3863 | GhostCode | 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 <iostream>
using namespace std;
unsigned long long fec(unsigned long long f)
{
if(f!=0)
{
return (f*fec(f-1))%1000000007;
}
return 1;
}
unsigned long long GenFind(unsigned long long* G,unsigned long long num)
{ //그 숫자세대의 토탈값
if(num==0)
{
return 0;
}
else if(num==1)
return 1;
else if(G[num]==NULL)
{
G[num]=(GenFind(G,num-1)+fec(num))%1000000007;
}
return G[num];
}
int main()
{
int D;
cin>>D;
unsigned long long *Gen = new unsigned long long[D];
unsigned long long *Position = new unsigned long long [D];
for (int i = 0; i<D;i++)
{
Gen[i]=NULL;
// cout<<GenFind(Gen,i)<<endl;
}
for(int i = 0; i<D;i++)
{
cin>>Position[i];
}
for(int i = 0; i<D;i++)
{
if(i==0)
cout<<"1"<<endl;
else if(i==1)
{
cout<< GenFind(Gen,i)+ Position[i]<<endl;
//부모값 + 이번위치
}
else
{
unsigned long long k =
(GenFind(Gen,i)+
(((Position[i-1]-1)*(i+1))%1000000007) +
Position[i])
%1000000007;
cout<< k<<endl;
//부모값 + 부모위치*현재세대값 + 이번위치
}
}
return 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |