wdmzjhyk @ 2024-11-21 10:40:20
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int S[101][101][101];
int w(int a,int b,int c)
{
if (a <= 0 || b <= 0 || c <= 0)
return 1;
if (S[a][b][c] != 0) return S[a][b][c];
if (a > 20 || b > 20 ||c > 20)
return w(20, 20, 20);
if (a < b && b < c)
return S[a][b][c]=w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c);
else return S[a][b][c]=w(a - 1, b, c) + w(a - 1, b - 1, c) + w(a - 1, b, c - 1) - w(a - 1, b - 1, c - 1);
return S[a][b][c];
}
int main()
{
int S[101][101][101] = { 0 };
int n,n1=0;
int s[3];
while (1)
{
scanf("%d %d %d", &s[0], &s[1], &s[2]);
if (s[0] == -1 && s[1] == -1 && s[2] == -1)
break;
int jieguo = w(s[0], s[1], s[2]);
printf("w(%d, %d, %d) = %d\n", s[0], s[1], s[2], jieguo);
}
return 0;
}
by complete_binary_tree @ 2024-11-21 11:17:41
不开 long long __
by complete_binary_tree @ 2024-11-21 11:22:03
还有应先判 a>20||b>20||c>20
再判 S[a][b][c]
是否有值