#include <iostream> #include "stdio.h" #include "stdlib.h" #include "string.h" #include "algorithm" #include <queue> using namespace std; int vis[22][22][22]; int ss[22][22][22]; int w(int a,int b,int c) { if(a<=0||b<=0||c<=0) return 1; if(a>20||b>20||c>20) return w(20,20,20); if(vis[a][b][c]==1) return ss[a][b][c]; if(a<b&&b<c) return w(a, b, c-1) + w(a, b-1, c-1) - w(a, b-1, c); return 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; memset(vis,0,sizeof vis); for(int i=1;i<=20;i++) for(int j=1;j<=20;j++) for(int k=1;k<=20;k++) { ss[i][j][k]=w(i,j,k); vis[i][j][k]=1; } while(scanf("%d%d%d",&a,&b,&c)!=EOF) { if(a==-1&&b==-1&&c==-1) return 0; else printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c)); } return 0; }
hdu 1331 (暴力打表)
最新推荐文章于 2021-08-06 20:00:12 发布