LeeBlog

导航

2011年5月6日 #

HDU 2049 不容易系列之(4)——考新郎

摘要: #include<stdio.h>long long num[25],N[25];int main( ){ num[1] = 0; num[2] = 1; N[1] = 1; N[2] = 2; N[0] = 1; for( int i = 3; i < 25; ++i ) num[i] = ( num[i-1] + num[i-2] )*( i - 1 ),N[i] = i * N[i-1]; int t,n,m; scanf( "%d",&t ); while( t-- ) { scanf( "%d%d",&n,&a 阅读全文

posted @ 2011-05-06 22:40 LeeBlog 阅读(314) 评论(0) 推荐(0) 编辑

HDU 2048 神、上帝以及老天爷 典型错排 DP

摘要: 这题我看了好几次,因为没学过错排,一直不敢做,今天看了下错排,可以用错排的公式做,但一神牛告诉我,可以DP,DP公式f( n ) = ( f( n - 1 ) + f( n -2 ) ) * ( n - 1 );#include<stdio.h>double num[25],N[25];void chart( ){ num[1] = 0; num[2] = 1; N[1] = 1; N[2] = 2; for( int i = 3; i < 25; ++i )//num[i]是错排 num[i] += ( num[i-1] + num[i-2] ) * ( i - 1 ),N 阅读全文

posted @ 2011-05-06 17:19 LeeBlog 阅读(546) 评论(0) 推荐(0) 编辑

HDU 2617 Happy 2009

摘要: 这题深受北大那题影响啊,这是链接http://www.cnblogs.com/Lvsi/archive/2011/04/10/2011484.html这题要注意happy的顺序不能变,所以要最先产生h然后a然后p,p,y,给每个字母都对应一个数组的数,要产生a时必须有h,要产生p时必须有a,要产生happy时,必须有一个h,一个a,两个p,一个y;而且要保证所有的happy都没颠倒次序,所以每一个字母的个数不能超过前面那个字母的个数( 例如hayppahppy,这种只有一个 )#include<stdio.h>#include<string.h>int n,num[5] 阅读全文

posted @ 2011-05-06 15:32 LeeBlog 阅读(258) 评论(0) 推荐(0) 编辑

HDU 2160 母猪的故事 水题... 斐波拉契数

摘要: #include<stdio.h>long long num[25];void chart( ){ num[0] = 0; num[1] = 1; num[2] = 2; for( int i = 3; i < 25; ++i ) num[i ] = num[i-1] + num[i-2]; }int main( ){ chart( ); int t,n; scanf( "%d",&t ); while( t-- ) { scanf( "%d",&n ); printf( "%I64d\n",num[ 阅读全文

posted @ 2011-05-06 13:36 LeeBlog 阅读(282) 评论(0) 推荐(0) 编辑