Short and fast recursion is definitely stuck. here we need to know a situation.
1. Is recursion repeated in many cases?
2. Is the "large-area data" generated by recursion combined with "small-range data?
If all answers are "yes ". We strongly recommend the "note-taking method ". If there is a note record, check the note; otherwise, recursive.
#include <stdio.h>long s[21][21][21] = {0};int w(int a,int b,int c){ if (a <= 0 || b <= 0 || c <= 0) return s[0][0][0]=1; if (a > 20 || b > 20 || c > 20) return w(20, 20, 20); if(s[a][b][c])return s[a][b][c]; 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);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);}int main(){ int a,b,c; while(1) { scanf("%d%d%d",&a,&b,&c); if(a==-1&&a==b&&a==c) break; printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c)); }return 0;}