标签:style blog class code tar c
#include <stdio.h> #include <string.h> const int N = 305; const int MOD = 1000000000; char str[N]; int n; long long f[N][N]; int main() { while (~scanf("%s", str)) { memset(f, 0, sizeof(f)); n = strlen(str); for (int len = 0; len < n; len += 2) { for (int l = 0; l + len < n; l++) { int r = l + len; if (l == r) f[l][r] = 1; for (int k = l + 2; k <= r; k+= 2) { if (str[l] == str[k] && str[k] == str[r]) { f[l][r] = (f[l][r] + f[l + 1][k - 1] * f[k][r]) % MOD; } } } } printf("%lld\n", f[0][n - 1]); } return 0; }
UVA 1362 - Exploring Pyramids(计数问题+区间DP),布布扣,bubuko.com
UVA 1362 - Exploring Pyramids(计数问题+区间DP)
标签:style blog class code tar c
原文地址:http://blog.csdn.net/accelerator_/article/details/25473107