I remember that I was able to solve a problem similar to this kind of problem by using a combination of mathematical methods. Unfortunately, I forgot and couldn't find it. Some people on the Internet also mentioned that I could use a combination of formulas to solve the problem, but no one has done it. They all use the DP method. It is very difficult to make it clear. We recommend two articles.
First look at this roughly: http://blog.csdn.net/crux_d/article/details/2206736
Look at his parsing when you want to implement it in detail: http://blog.csdn.net/yan_____/article/details/8719748
# Include <iostream> # include <cstdio> # include <list> # include <algorithm> # include <cstring> # include <string> # include <queue> # include <stack> # include <map> # include <vector> # include <cmath> # include <memory. h> # include <set> # include <cctype> # define ll long # define ll _ int64 # define EPS 1e-8 # define INF 0 xfffffff // const ll INF = 1ll <<61; using namespace STD; // vector <pair <int, int> G; // typedef pair <int, int> P; // vector <pair <int, int>:: iterator ITER; // Map <LL, int> MP; // Map <LL, int>: iterator P; ll DP [12] [10000]; // Number of placement methods in row I status J int binary [15000] [2]; // [I] [0] indicates the status of the current row, [I] [1] indicates the status of the next row that matches [I] [0]. Vertical placement affects int W, H, CNT; void Init () {CNT = 0; memset (DP, 0, sizeof (DP);} void DFS (int n, int now, int NEX) {If (n> W) return; // There is another N + 2, so it may be greater than W directly without generating a value equal to WIF (n = W) {binary [CNT] [0] = now; binary [CNT ++] [1] = NEX; return;} DFS (n + 2, (now <2) + 3, (NEX <2) + 3 ); DFS (n + 1, (now <1) + 1, NEX <1); DFS (n + 1, now <1, (NEX <1) + 1) ;}int main () {While (scanf ("% d", & W, & H), w + H) {Init (); DFS (0, 0); DP [0] [(1 <W)-1] = 1; // The boundary must be filled with 1for (INT I = 0; I
Zoj1100 pressure DP + Deep Search