hdu 1398
HDU
2023-09-27 14:23:51 时间
题目大意:输入是一个整数。输出他的拆分数(即拆分的方案数),本题与1028最大的不同之处就在于他的面额只能是整数的平方
代码如下:
/* * 1398_1.cpp * * Created on: 2013年8月9日 * Author: Administrator */ #include <stdio.h> int main(){ //数组要开到比n值大 int n , c1[310],c2[310]; while(scanf("%d",&n),n){ int i,j,k; for(i = 0 ; i <= n ; ++i){ c1[i] = 1; c2[i] = 0; } for(i = 2 ; i*i <= n ; ++i){ for(j = 0 ; j <=n ; ++j){ for(k = 0 ; k+j <= n ; k+=i*i ){ c2[j+k] += c1[j]; } } for(j = 0 ; j <= n ; ++j){ c1[j] = c2[j]; c2[j] = 0; } } printf("%d\n",c1[n]); } }
相关文章
- hdu杭电1856 More is better【并查集】
- HDU 5510 Bazinga
- HDU 5491 The Next
- HDU 5438 Ponds
- HDU 4467 Graph
- HDU 4824 Disk Schedule
- HDU 1540 Tunnel Warfare
- HDU 2126 Buy the souvenirs
- HDU 1506 Largest Rectangle in a Histogram
- HDU 1251 统计难题
- HDU 2647 Reward
- HDU 5241 Friends (大数)
- HDU 4496 D-City (并查集)
- HDU 5438 Ponds (DFS,并查集)
- HDU 3363 Ice-sugar Gourd (贪心)
- HDU 5389 Zero Escape(dp啊 多校)
- HDU 5358 First One(枚举)
- HDU-2035 (快速幂)