Food (Bzoj 3280)

Source: Internet
Author: User

Description obviously this time to go out to travel, and the last difference is that he will go to the universe adventure! We won't talk about how NC he is, and he fancies what he should bring. Of course, you have to help him calculate the number of programs carrying n items.            He is ready to bring some popular food, such as: peach, chicken, Chengde, etc. of course, he has some strange restrictions: each food limit is as follows: Chengde Burger: Even Coke: 0 or 1 chicken legs: 0, 1 or 2            Peach: Odd number of chicken nuggets: 4 times the number of buns: 0, 1, 2 or 3 potato slices fried meat: no more than one. Bread: 3 times the number of notes, here we do not bother to think clearly about the food with what to eat, also think that each kind of food is "a" unit (anyway is fantasy), as long as the total sum up is n even a scheme. Therefore, for the given n, you need to calculate the number of scenarios and modulo 10007.Input Example 11 Output Example 1 1 Input Sample 2 5 output Sample 2 35 data range for 40% data,1<=n<=100000; For all data,1<=n<=10^500;
/*the question is not very good, look at the problem of a certain Daniel (http://blog.csdn.net/popoqqq/article/details/42805975), say something about your understanding of the parent function. The generating function for a sequence {0,1,2,3,4,5...N} is: F (x) =0+x+2x^2+3x^3+4x^4+...+nx^n the burger for this problem, the scheme number for volume I is {1,0,1,0,1 ...}, and the build function is f (x) =1+x^2+x ^4 ... (probably this way) as for the following, use the inverse (or geometric series sum) to simplify, then multiply all the equations, and then become C (n+2,3). (Good Magic)*/#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#defineM 510#defineMOD 10007using namespacestd; intN; CharS[m]; intMain () {inti; scanf ("%s", s+1);  for(i=1; s[i];i++) (n= (n<<1) + (n<<3) + (s[i]-'0'))%=MOD; cout<< (N (n+1)%mod* (n+2)%mod*1668%MOD) <<endl;//This 1668 is very metaphysical ah ...     return 0; }

Food (Bzoj 3280)

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.