# BZOJ 1600: [Usaco2008 Oct]建造栅栏( dp )

QAQ我没读过书...四边形都不会判定了

------------------------------------------------------------------------------

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>

#define rep( i , n ) for( int i = 0 ; i < n ; i++ )
#define clr( x , c ) memset( x , c , sizeof( x ) )
#define Rep( i , n ) for( int i = 1 ; i <= n ; ++i )

using namespace std;

const int maxn = 2500 + 5;

int dp[ 5 ][ maxn ];

int main() {
// freopen( "test.in" , "r" , stdin );
int n;
cin >> n;
int m = ( ( n + 1 ) >> 1 ) - 1;
dp[ 0 ][ 0 ] = 1;
Rep( i , 4 )
Rep( j , n )
Rep( k , min( j , m ) )
dp[ i ][ j ] += dp[ i - 1 ][ j - k ];
cout << dp[ 4 ][ n ] << "\n";
return 0;
}

------------------------------------------------------------------------------

## 1600: [Usaco2008 Oct]建造栅栏

Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 941  Solved: 551
[Submit][Status][Discuss]

*第一行：一个数n

*第一行：合理的方案总数

6

## Sample Output

6

Farmer John能够切出所有的情况为: (1, 1, 1,3); (1, 1, 2, 2); (1, 1, 3, 1); (1, 2, 1, 2); (1, 2, 2, 1); (1, 3,1, 1);
(2, 1, 1, 2); (2, 1, 2, 1); (2, 2, 1, 1); or (3, 1, 1, 1).

## Source

posted @ 2015-06-08 09:15  JSZX11556  阅读(188)  评论(0编辑  收藏  举报