【OpenJudge|【OpenJudge 1665】完美覆盖

http://noi.openjudge.cn/ch0405/1665/?lang=zh_CN
状压水题,手动转移

#include #include #include using namespace std; int in() { int k = 0, fh = 1; char c = getchar(); for(; c < '0' || c > '9'; c = getchar()) if (c == '-') fh = -1; for(; c >= '0' && c <= '9'; c = getchar()) k = k * 10 + c - 48; return k * fh; }int f[103][8], n; int main() { f[0][7] = 1; for(int i = 1; i <= 30; ++i) { f[i][1] = f[i - 1][6]; f[i][2] = f[i - 1][5]; f[i][3] = f[i - 1][4] + f[i - 1][7]; f[i][4] = f[i - 1][3]; f[i][5] = f[i - 1][2]; f[i][6] = f[i - 1][1] + f[i - 1][7]; f[i][7] = f[i - 1][3] + f[i - 1][6] + f[i - 2][7]; } while ((n = in()) != -1) printf("%d\n", f[n][7]); return 0; }

【【OpenJudge|【OpenJudge 1665】完美覆盖】转载于:https://www.cnblogs.com/abclzr/p/5957990.html

    推荐阅读