bzoj1600 [Usaco2008 Oct]建造栅栏(递推)
Description
Input
*第一行:一个数n
Output
*第一行:合理的方案总数
Sample Input
Sample Output
输出详解:
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).
下面四种
(1, 1, 1, 3), (1, 1, 3, 1), (1, 3, 1, 1), and (3,1, 1, 1) – 不能够组成一个四边形.
#include<iostream>
#include<cstdio>
#include<cstring>
#define re register
using namespace std;
int min(int &a,int &b){return a<b?a:b;}
int n,f[][];
int main(){
scanf("%d",&n);
f[][]=; int mx=((n+)>>)-;
for(re int i=;i<=;++i)
for(re int j=i;j<=n-+i;++j)
for(re int u=min(mx,j);u>=;--u)
f[i][j]+=f[i-][j-u];
printf("%d",f[][n]);
return ;
}
bzoj1600 [Usaco2008 Oct]建造栅栏(递推)的更多相关文章
- BZOJ1600: [Usaco2008 Oct]建造栅栏
1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 825 Solved: 473[Submit][Sta ...
- BZOJ 1600: [Usaco2008 Oct]建造栅栏
1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MB Description 勤奋的Farmer John想要建造一个四面的 ...
- BZOJ 1600: [Usaco2008 Oct]建造栅栏( dp )
QAQ我没读过书...四边形都不会判定了 简单的dp.... --------------------------------------------------------------------- ...
- 【BZOJ】1600: [Usaco2008 Oct]建造栅栏(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1600 说好的今天开始刷水.. 本题一开始我以为是排列组合,但是自己弱想不出来,只想到了如果四边有一条 ...
- BZOJ 1600 [Usaco2008 Oct]建造栅栏:dp【前缀和优化】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1600 题意: 给你一个长度为n的木板,让你把这个木板切割成四段(长度为整数),并且要求这四 ...
- bzoj 1600: [Usaco2008 Oct]建造栅栏【dp】
要求三边和大于第四边,所以任意一条边的长度都是小于n/2 设f[i][j]为前i条长为j,转移的时候用n/2限制 #include<iostream> #include<cstdio ...
- bzoj 1600 & Usaco 月赛 2008 建造栅栏 题解
[原题] 1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 785 Solved: 443 [Subm ...
- 【66测试20161115】【树】【DP_LIS】【SPFA】【同余最短路】【递推】【矩阵快速幂】
还有3天,今天考试又崩了.状态还没有调整过来... 第一题:小L的二叉树 勤奋又善于思考的小L接触了信息学竞赛,开始的学习十分顺利.但是,小L对数据结构的掌握实在十分渣渣.所以,小L当时卡在了二叉树. ...
- bzoj1601: [Usaco2008 Oct]灌水
经典延伸最小生成树问题... #include<cstdio> #include<cstring> #include<cctype> #include<alg ...
随机推荐
- eclipse启动错误
1.错误日志 !SESSION 2013-12-09 12:24:33.826 -----------------------------------------------eclipse.build ...
- ruby+gem常用命令
gem是一种文件组织的包,一般的ruby的很多插件都有由这种各种的包提供.我们来看看gem的用法 ruby -v #查看ruby 版本 ruby -e ''require"watir ...
- LeetCode——First Bad Version
Description: You are a product manager and currently leading a team to develop a new product. Unfort ...
- JZOJ.5331【NOIP2017模拟8.23】壕游戏
Description
- Java可视化JVM监控软件
jdk自带.jdk安装目录下 1.JConsole 选择 不安全 可用不多 2.VisualVM
- handlebars的使用
web 开发中,js 解析JSON 是经常的事情.非常繁琐.handlebars 使用了模版,只要你定义一个模版,提供一个json对象,handlebars 就能吧json对象放到你定的模版中 htm ...
- POJ2286 The Rotation Game[IDA*迭代加深搜索]
The Rotation Game Time Limit: 15000MS Memory Limit: 150000K Total Submissions: 6325 Accepted: 21 ...
- 沈阳网络赛D-Made In Heaven【k短路】【模板】
One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. However, Pucci ...
- go 工具链目前[不支持编译 windows 下的动态链接库]解决方案
go 工具链目前[不支持编译 windows 下的动态链接库][1],不过[支持静态链接库][2].想要产生dll,可以这样 workaround ,参考 golang [issuse#11058][ ...
- linux加载硬盘过程
查看系统可用磁盘大小: [root@i-mbyar7df ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 ...