Pagini recente » Cod sursa (job #800996) | Cod sursa (job #637510) | Cod sursa (job #1003870) | Cod sursa (job #826822) | Cod sursa (job #1971984)
#include <fstream>
using namespace std;
ifstream in("arbori.in");
ofstream out("arbori.out");
int const NMAX = 90;
int n, m, k;
long long sol[1 + NMAX][1 + 10][1 + NMAX], res;
int aux(int a){
int z = a % m;
if(z < 0)
z += m;
return z;
}
int main()
{
in >> n >> m >> k;
in.close();
for(int i = 0; i <= n; i++)
sol[1][0][i] = 1;
for(int i = 2; i <= n; i++){
int x = aux(i - 1);
sol[i][x][1] = 1;
for(int j = 2; j <= n; j++){
for(int k = 0; k < m; k++){
res = 1;
for(int l = 0; l * j < i; l++){
sol[i][k][j] += sol[i - j * l][aux(k - l)][j - 1] * res;
res *= sol[j][aux(j-1)][j-1] + l;
res /= (l + 1);
}
}
}
}
out << sol[n][k][n - 1] << '\n';
out.close();
return 0;
}