BZOJ4563[HAOI2016] put a pawn
Test instructions
Give you a n*n matrix, each row has an obstacle, the data guarantees that any two obstacles are not in the same row, any two obstacles are not in the same column. ask you to put n pieces (the position of the barrier can not play chess pieces), but also to meet each row only one piece, each column only a piece of the limit, ask how many kinds of programs. n≤200.The following:Find out where the obstacle is and the answer is irrelevant. So you can put the pieces into the upper left-right diagonal, then the problem of the wrong row (an arrangement of length n, requires that each element cannot be placed in the same position as its own number, ask how many scenarios to meet the conditions). Mismatch formula: f[i]= (F[i-1]+f[i-2]) * (i-1), special, f[0]=1,f[1]=0. Ben Weak too lazy, do not want to write high precision, wrote a python, the result because will not write WA several hair qaqCode:
1 n=Int (raw_input ())2 a=13 b=04 for in range (2,n+1): 5 c= (a+b) * (i-1)6 a=b7 b=c8Print b
Python's highlighting is so ugly!
20160814
BZOJ4563[HAOI2016] put a pawn