【生成函数】 Step 5 HDU 2069

BabbleDay posted @ 2013年7月24日 00:44 in 刷题防身 , 703 阅读

详解见:http://bonniebbs.is-programmer.com/posts/40073.html

#include <iostream>
#include <cstring>
#define N 255
#define M 105
using namespace std;

int main()
{
    int i, j, k, l, n;
    int num[6] = {0,1,5,10,25,50};
    int c1[N][M], c2[N][M], ans[N];
    memset(c1, 0, sizeof(c1));
    memset(c2, 0, sizeof(c2));
    memset(ans, 0, sizeof(ans));
    c1[0][0] = 1;
    for(int i=1; i<6; i++)
    {
        for(int j=0; j<=250; j++)
        {
            for(int k=0; k*num[i]+j<=250; k++)
            {
                for(int l=0; l+k<=100; l++)
                {
                    c2[j+k*num[i]][l+k] += c1[j][l];
                }
            }
        }
        for(int x=0; x<=250; x++)
        {
            for(int y=0; y<=100; y++)
            {
                c1[x][y] = c2[x][y];
                c2[x][y] = 0;
            }
        }
    }
    for(int i=0; i<=250; i++)
        for(int j=0; j<=100; j++)
            ans[i] += c1[i][j];
//    for(int i=0; i<=250; i++) cout << ans[i] << " " ;
    while(cin >> n)
        cout << ans[n] << endl;
    return 0;
Avatar_small
NCERT Maths Exempla 说:
2023年9月08日 00:22

Exemplar Problems and Solutions Required for CBSE Exam, as well as useful to form the Foundation in the NCERT Examination, Students Download the latest NCERT Maths Exemplar Problems Class 9 in Pdf Format, in both Hindi and English. Urdu Medium You can also buy them from the links given.Our website we are Providing the NCERT Maths Exemplar 2024 for all Chapters of class 9, All the Questions are NCERT Maths Exemplar Problems for 9th Class 2024 very Important for the Upcoming class 9 Maths Exam, All the NCERT Class 9 Exemplar Solutions 2024 have been Explained in a way to help Students Thoroughly Understand the concept.For All class 9 Students Preparing for their Maths Exam 2024, Solving the NCERT Maths Exemplar Problems 2024 is the best way to Tackle the Complex Problems asked in Science Exam, we are Providing the NCERT Class 9 Maths Exemplar Problems


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter