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<bits/stdc++.h>
using namespace std;
const int MOD = (int)(1e9+7);
long long dp[1024];
int main()
{
long long n,a,b,c,l,i,j;
cin>>n;
dp[1]=1;
for(i=2;i<=n;i++)
{
a=1;
for(j=2;j<=i;j++)a*=j;
for(j=i-1;j>=1;j--)
{
b=1;
for(l=1;l<=j;l++)b*=l;
c=1;
for(l=1;l<=i-j;l++)c*=l;
dp[i]+=(dp[j]*((a/(b*c))%MOD));
dp[i]%=MOD;
}
dp[i]+=1;
dp[i]%=MOD;
}
cout<<dp[n]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |