BZOJ4563[HAOI2016] put a pawn

Source: Internet
Author: User
Tags for in range

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.