"The unique decomposition theorem of combinatorial number" Uva1635

Source: Internet
Author: User

Give N, M, obtain the final summation sequence an=c (n-1,0) *x1 + C (n-1,1) *x2+...+c (n-1,n-1) *xN;

If Xi is not related to M, the remainder of an divided by M is not related to Xi, i.e. the remainder does not contain the term XI;

Input: N,m

Output: The total number of ans//unrelated items;

Xi1 xi2 ...//unrelated items, ascending

Tips:

The unique decomposition theorem for combinatorial numbers

Because the number of 10^5-level combinations is bound to be large (long long or even double cannot be saved), it is required that the unique decomposition can only take a recursive step-down decomposition, the code is as follows:

BOOLCheckintNintJ//calculates the exponent of the unique decomposition of C (N, j) According to the recursive formula{    intnum = fac[0][0];//This is the total number of element factors calculated for the previous step    intA = N-j +1; intb =J;  for(inti =1; I <= num; i++)    {        intp = fac[i][0]; int&q =Fac_c[i]; ///calculate the decomposition index         for(; a%p = =0; A/= p, q++);  for(; b%p = =0; b/= P, q--); }}

After the completion of the comparison between the factor index and the M-only decomposition of the corresponding exponent size can be

"The unique decomposition theorem of combinatorial number" Uva1635

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.