HDU1284 coin exchange issues (tables of the master function)

Source: Internet
Author: User

Problem: Use the primary function to create a table. because the value of the coin is given and remains unchanged, there are only three expressions, G (x) = (1 + x ^ 2 + x ^ 3 + ...... + X ^ MAX) (1 + x ^ 2 + x ^ 4 + ...... + X ^ 2 * MAX) (1 + x ^ 3 + x ^ 6 + ...... + X ^ 3 * MAX); Put the loop outside, or else TEL;

# Include <cstdio> using namespace std; # define MAX 32768 int a1 [MAX], a2 [MAX]; void init () // brute force table hitting {int I, j, k; for (I = 0; I <MAX; I ++) {a1 [I] = 1; a2 [I] = 0 ;}for (I = 2; I <= 3; I ++) {for (j = 0; j <MAX; j ++) for (k = 0; k + j <MAX; k + = I) a2 [j + k] + = a1 [j]; for (j = 0; j <MAX; j ++) {a1 [j] = a2 [j]; a2 [j] = 0 ;}} int main () {init (); int n; while (scanf ("% d", & n )! = EOF) printf ("% d \ n", a1 [n]); return 0 ;}

 

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.