HDU 2082 找单词
这题是母函数的一基本题。跟2079差不多http://www.cnblogs.com/Lvsi/archive/2011/05/11/2043707.html
不过这里相邻括号递增的幂是依次递增的,不过这次我又犯了一个错误,很严重的,在写k的时候竟然写成k*i<= map[i]
oh~ so bad ... 以后谨记
#include<stdio.h> int map[28],m1[100],m2[100],n; void gf( ) { m1[0] = 1; for( int i = 1; i <= 26; ++i ) { for( int j = 0; j <= 50; ++j ) for( int k = 0; (k*i + j <= 50) && k <= map[i]; k ++ ) m2[j + k*i] += m1[j]; for( int j = 0; j <= 50; ++j ) m1[j] = m2[j],m2[j] = 0; } } int main( ) { scanf( "%d",&n ); while( n-- ) { for( int i = 0; i < 100; ++i ) m1[i] = m2[i] = 0; for( int i = 1; i <= 26; ++i ) scanf( "%d",&map[i] ); gf( ); int sum = 0; for( int j = 1; j <= 50; ++j ) sum += m1[j]; printf( "%d\n",sum ); } return 0; }
本人还是新手 ,转载请注明来自Lvsi‘s home