【生成函数】Step 1 HDU 1398

BabbleDay posted @ 2013年7月23日 22:54 in 刷题防身 , 607 阅读

 

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

#include <iostream>
#include <cstdio>
#define N 305
using namespace std;

int main()
{
    int n;
    int c1[N], c2[N];
    while(scanf("%d", &n), n)
    {
        for(int i=0; i<=n; i++)
        {
            c1[i] = 1;
            c2[i] = 0;
        }
        for(int i=2; i*i<=n; i++)
        {
            for(int j=0; j<=n; j++)
            {
                for(int k=0; k+j<=n; k+=i*i)
                {
                    c2[k+j] += c1[j];
                }
            }
            for(int j=0; j<=n; j++)
            {
                c1[j] = c2[j];
                c2[j] = 0;
            }
        }
        cout << c1[n] << endl;
    }
    return 0;
}
Avatar_small
9th Class Exemplar 说:
2023年8月23日 18:47

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 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 9th for all Chapters of class All the Questions are 9th Class Exemplar Problem for NCERT 2024 very Important for the Upcoming class Exam, All the NCERT Class Exemplar Solutions 2024 for English, Hindi, Mathematics, Sanskrit, Science, Social Science, Urdu have been Explained in a way to help Students Thoroughly Understand the concept


登录 *


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