zoukankan      html  css  js  c++  java
  • HDU 1028 Ignatius and the Princess III(母函数整数拆分)

    链接:传送门
    题意:一个数n有多少种拆分方法
    思路:典型母函数在整数拆分上的应用

    /*************************************************************************
        > File Name: 1.cpp
        > Author:    WArobot 
        > Blog:      http://www.cnblogs.com/WArobot/ 
        > Created Time: 2017年04月20日 星期四 21时07分09秒
     ************************************************************************/
    
    #include<bits/stdc++.h>
    using namespace std;
    
    int p[130] , a[130] , b[130];
    int n;
    
    void init(){
    	for(int N = 1;N<=120;N++){
    		for(int i=0;i<=N;i++)	a[i] = 1 , b[i] = 0;
    		for(int i=2;i<=N;i++){
    			for(int j=0;j<=N;j++)
    				for(int k=0;k*i+j<=N;k++)	b[k*i+j] += a[j];
    			for(int j=0;j<=N;j++)			a[j] = b[j] , b[j] = 0;
    		}
    	}
    }
    int main(){
    	init();
    	while(scanf("%d",&n)!=EOF && n){
    		printf("%d
    ",a[n]);
    	}
    	return 0;
    }
  • 相关阅读:
    7.12.2
    7.12.1
    7.11.8
    循环测试条件前缀和后缀的区别
    7.11.7 两个版本
    7.11.5
    7.12 vowels.c 程序
    7.11 animals.c 程序
    7.6.2 break 语句
    7.10 break.c 程序
  • 原文地址:https://www.cnblogs.com/WArobot/p/6749036.html
Copyright © 2011-2022 走看看