本来是一道插头dp的题目,可是CLJ来一句打表,这个题就被结束了。。。
#include <cstdio>
#include <cstring>
#include <cstdlib>
int ans[7][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 2, 3, 4, 5, 6},
{0, 0, 6, 15, 28, 45, 66, 91},
{0, 0, 0, 52, 143, 350, 799, 1744},
{0, 0, 0, 0, 614, 2431, 9184, 33603},
{0, 0, 0, 0, 0, 16000, 102147, 637330},
{0, 0, 0, 0, 0, 0, 1114394, 11948355}
};
int main() {
int A, B;
scanf("%d %d", &A, &B);
if (A > B) { int t = A; A = B; B = t; }
printf("%d\n", ans[A][B]);
return 0;
}
本文讨论了一道原本需要使用插头dp解决的编程问题,但作者通过引入打表技巧,轻松地解决了这个问题。展示了打表在解决特定类型问题时的高效性。
474

被折叠的 条评论
为什么被折叠?



