Cod sursa(job #2629414)
| Utilizator | Data | 20 iunie 2020 16:29:18 | |
|---|---|---|---|
| Problema | Arbori | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
using namespace std;
ifstream cin("arbori.in");
ofstream cout("arbori.out");
typedef long long ll;
ll n,m,k,ans;
ll dp[100][100];
ll tot[100];
int main()
{
cin>>n>>m>>k;
tot[1]=1;
dp[1][0]=1;
for(ll subg=1;subg<n;++subg)
for(ll card=subg+1;card<=n;++card)
for(ll app=1;app<n;++app)
{
dp[card][app]+=dp[card-subg][app-1]*tot[subg];
if((app+1)%m==k) tot[card]+=dp[card][app];
}
if(k==0) k=m;
for(int i=k;i<n;i+=m)
ans+=dp[n][i];
cout<<ans<<'\n';
return 0;
}
