HDU 1028 Ignatius and the princess III (primary function)

Source: Internet
Author: User
/// Integer sharding template // g (x) = (1 + x ^ 2 ...) (1 + x ^ 2 + x ^ 4 ...) (1 + x ^ 3 + x ^ 6 ...) # include <stdio. h> # include <algorithm> # include <string. h ># include <iostream> using namespace STD; int main () {int N, I, J, K, c1 [125], C2 [125]; while (~ Scanf ("% d", & N) {// initialization, corresponding to the first expression (1 + x ^ 2 ....), this is only one case between (0, n) I for (I = 0; I <= N; I ++) {c1 [I] = 1; /// Save the number of numbers that can be combined. C2 [I] = 0; // intermediate quantity, save every time} // start from the second expression for (I = 2; I <= N; I ++) {for (j = 0; j <= N; j ++) // J from 0 to N enumeration {for (k = 0; k + j <= N; k + = I) /// enumerate the exponent of expression I from K. The exponential increment of expression I is I {c2 [K + J] + = c1 [J];} for (j = 0; j <= N; j ++) // assign the value of C2 to C1, because every time C2 starts from another expression, {c1 [J] = c2 [J]; c2 [J] = 0 ;}} printf ("% d \ n ", c1 [N]);} return 0 ;}

HDU 1028 Ignatius and the princess III (primary function)

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.