#include <iostream>
using namespace std;
long long fec(long long f)
{
if(f!=0)
{
return (f*fec(f-1))%1000000007;
}
return 1;
}
long long GenFind(long long* G,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(void)
{
int D;
cin>>D;
long long *Gen = new long long[D];
long long *Position = new 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";
else
{
long long k =
((GenFind(Gen,i)%1000000007)+
(((Position[i-1]-1)*(i+1))%1000000007) +
(Position[i])%1000000007)%1000000007;
cout<<k;
//부모값 + 부모위치*현재세대값 + 이번위치
}
if(i!=D-1)
{
cout<<endl;
}
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1672 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |