Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/10000 K (Java/Others)
#include <cstdio> #include <iostream> using namespace std; const int MAXN = 2000 + 5; bool dp[MAXN][MAXN]; void Init() { for(int i=0; i<MAXN; i++) dp[0][i] = dp[i][0] = 1; for(int i=1; i<MAXN; i++) { for(int j=1; j<MAXN; j++) { dp[i][j] = !(dp[i-1][j] && dp[i-1][j-1] && dp[i][j-1]); } } } int main () { Init();int n, m; while(~scanf("%d%d", &n, &m) && (m|n)) { printf("%s\n", dp[n][m]?"Wonderful!":"What a pity!"); } return 0; }
原文:http://www.cnblogs.com/AcIsFun/p/5369958.html