| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 3957 | GhostCode | Inherited disease (kriii1_I) | C++98 | 0 ms | 1672 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
|---|---|---|---|---|
| Fetching results... | ||||
