Zoj 3725 painting storages DP + sort count

Source: Internet
Author: User

Reprinted on http://blog.csdn.net/zu_xu/article/details/9401497

Recurrence: WHEN n <m, there is no method that meets the conditions. Therefore, the result is 0; when n = m, the number of solutions is exactly 1. N> M, if 1 to the N-1 to meet the conditions, N can be any dyeing, the number of C (N-1) * 2; otherwise, there must be 1 to the N-M-1 does not meet the conditions, n-M is blue, N-M + 1 to N-1 is red, then dye n red, the number of the solution is 2 ^ (N-M-1)-C (N-M-1 ), that is, the number of dyeing schemes from 1 to N-M-1 minus the number of solutions that meet the conditions.

 # include 
  
    # include 
   
     # define mod 1000000007 typedef long ll; ll pow2 [100000]; ll ITER [100001]; int main () {int n, m; * pow2 = 1; for (INT I = 1; I <100000; ++ I) pow2 [I] = (pow2 [I-1] * 2) % MOD; while (~ Scanf ("% d", & N, & M) {If (n 
    
   
  

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.