先咕着
---------------2018 5 22----------------------

题解

生成函数处理整数拆分

code

#include<cstdio>    
#include<cstring>   
#include<algorithm>  
inline int raed() { 
	int x = 0,f = 1; 
	char c = getchar(); 
	while(c < '0' || c < '9') c = getchar(); 
	while(c <= '9' && c >= '0')x = x * 10 + c - '0',c = getchar(); 
	return x * f; 
} 
const int maxn = 564; 
int a[maxn],b[maxn]; 
int main() { 
	int n; 
	while(scanf("%d",&n) == 1) { 
		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 + j <= n;k += i) 
					b[j + k] += a[j]; 
			for(int j = 0;j <= n;++ j) 
				a[j] = b[j],b[j] = 0; 
		} 
		printf("%d\n",a[n]); 
	}
	return 0; 
} 

相关文章:

  • 2021-09-22
  • 2021-06-15
  • 2021-10-27
  • 2022-01-24
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2021-11-02
  • 2021-07-24
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
相关资源
相似解决方案