两个典型的例题:POJ 1753, POJ 2965;
POJ 1753 状态转移:
1 int Flip(int pos, int i) {
2 pos ^= (1<<i);
3 if(i+4 < 16) pos ^= (1<<(i+4));
4 if(i-4 >= 0) pos ^= (1<<(i-4));
5 if(i%4+1<4) pos ^= (1<<(i+1));
6 if(i%4-1>=0) pos ^= (1<<(i-1));
7 return pos;
8 }
POJ 2965 状态转移:(这题的输出结果是不是要排序??)
1 int change(int pos, int i) {
2 pos ^= (1<<i);
3 int r, c, k;
4 r = i/4; c = i%4;
5 for(k = 0; k < 4; k++) {
6 pos ^= (1<<(r*4+k));
7 pos ^= (1<<(c+4*k));
8 }
9 return pos;
10 }
ps : 姑且称之为状态转移吧,因为感觉跟动态规划中转移状态这个思路差不多的。^_^