Ultraviolet A 11806-Cheerleaders (rejection principle + binary)

Source: Internet
Author: User

Ultraviolet A 11806-Cheerleaders (rejection principle + binary)

 

Question:

Place k stones in a grid of n rows and m columns. How many methods are there? The first, first, last, and last columns must contain stones.

Ideas:

1. Expansion of the principle of rejection

Assume that there are three sets, S, and three other sets, a B c, do not belong to A, B, C, any set, but belong to the elements of the complete set, odd subtraction; even Addition

Here, S is an empty Set A, B, C, and D, respectively, representing four situations in the row column:

AUBUCUD = | A | + | B | + | C | + | D |-| AB |-| BC |-| AC |-| AD |-| BD |-| CD | + | ABC | + | ABD | + | ACD | + | BCD |-| ABCD |

If A or B is in the Set, A row is missing; if C or D is in the Set, A column is missing.

Assuming that the row and col columns are left at the end, the number of methods is C (row * col, k ).

2. binary representation of the combination of four conditions

3. Calculate the number of combinations: C (n + 1, k + 1) = c (n, k + 1) + (n, k)

 

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Define deusing namespace std; typedef long LL; # define MOD 1000007 # define MAX 510int c [MAX] [MAX]; void C () // calculate the number of combinations {memset (c, 0, sizeof (c); c [0] [0] = 1; for (int I = 0; I <= 500; I ++) {c [I] [0] = c [I] [I] = 1; for (int j = 1; j
     
      

 

 

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.