#include<iostream>
using namespace std;
int n, a[10] = { 1,1,1,1,1,1,1,1,1,1 };
void season(int n, int m, int l)
{
if (9 == l && 1 == m && n >= 1 && n <= 3)
{
a[9] += n - m;
for (int i = 0; i < 10; i++)
cout << a[i] << ' ';
cout << endl;
a[9] -= n - m;
}
else if (3 * m >= n)
for (int i = 0, j = l; i <= min(2, n - m); i++)
{
a[l] += i;
season(n - a[l], m - 1, l + 1);
a[l] -= i;
}
}
long long count(int n, int m)
{
if (n < 0 || 2 * m < n)
return 0;
else if (0 <= n && n <= 2 && 1 == m || 0 == n)
return 1;
else
return count(n, m - 1) + count(n - 1, m - 1) + count(n - 2, m - 1);
}
int main()
{
cin >> n;
if (n < 10 || n>30)
cout << '0';
else
{
cout << count(n - 10, 10) << endl;
season(n, 10, 0);
}
return 0;
}
洛谷P2089 烤鸡进阶解法
最新推荐文章于 2021-09-06 23:11:13 发布