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 ...
随机推荐
- 使用ASIHTTPRequest xcode编译提示找不到"libxml/HTMLparser.h"
使用ASIHTTPRequest xcode编译提示找不到"libxml/HTMLparser.h",解决方法如下: 1>.在xcode中左边选中项目的root节点,在中间编 ...
- Linux应急响应思路详谈
一.主机篇: 1.自动化初筛,建议使用RootkitHunter (1)安装 $sudo wget https://jaist.dl.sourceforge.net/project/rkhunter/ ...
- maven安装和与IDE集成
第一部分:maven的基本信息和安装,配置 maven是一个项目构建和管理的工具,提供了帮助管理 构建.文档.报告.依赖.scms.发布.分发的方法.可以方便的编译代码.进行依赖管理.管理二进制库等 ...
- highmaps如何自定义 区间的颜色刻度
https://api.highcharts.com/highmaps/colorAxis.dataClassColor http://jsfiddle.net/gh/get/library/pure ...
- jQuery --- 收集表单
第一种:常用获取对应表单的value值进行收集: 第二种:用jQuery的 serializeArray() 方法收集: <form id="change"> < ...
- 最优比例生成环(dfs判正环或spfa判负环)
http://poj.org/problem?id=3621 Sightseeing Cows Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- 徐州网络赛B-BE,GE or NE【记忆化搜索】【博弈论】
In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...
- Java的平台无关性如何体现出来的
传统的编程中,源代码编译为可执行的代码后,只能针对特定的平台(操作系统),换句话说,针对Windows编写和编译的代码,只能在Windows上运行... java程序则编译为字节码.字节码本身不能运行 ...
- jQuery 的attr()方法
在JS中设置节点的属性与属性值用到setAttribute(),获得节点的属性与属性值用到getAttribute(),而在jquery中,用一个attr()就可以全部搞定了,赞一个先 ^^ jque ...
- Mysql EXPLAIN 相关疑问: Using temporary ; Using filesort
一.什么是Using temporary ; Using filesort 1. using filesort filesort主要用于查询数据结果集的排序操作,首先MySQL会使用sort_buff ...