标签:des style blog io ar os sp for on
Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <set> #include <map> #include <vector> #include <queue> #include <string> #define inf 0x3fffffff #define eps 1e-10 using namespace std; int f[25][25][25]; void Init() { for (int i = 0; i <= 20; i++) for (int j = 0; j <= 20; j++) f[i][j][0] = f[i][0][j] = f[0][i][j] = 1; for (int i = 1; i <= 20; i++) for (int j = 1; j <= 20; j++) for (int k = 1; k <= 20; k++) { if (i < j && j < k) f[i][j][k] = f[i][j][k-1] + f[i][j-1][k-1] - f[i][j-1][k]; else f[i][j][k] = f[i-1][j][k] + f[i-1][j-1][k] + f[i-1][j][k-1] - f[i-1][j-1][k-1]; } } 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 f[20][20][20]; return f[a][b][c]; } int main() { //freopen("test.txt", "r", stdin); Init(); int a, b, c; while (scanf("%d%d%d", &a, &b, &c) != EOF) { if (a == -1 && b == -1 && c == -1) break; printf("w(%d, %d, %d) = ", a, b, c); printf("%d\n", w(a, b, c)); } return 0; }
ACM学习历程——HDU1331 Function Run Fun(锻炼多维dp的打表)
标签:des style blog io ar os sp for on
原文地址:http://www.cnblogs.com/andyqsmart/p/4111449.html