codeforces 617B Chocolate
题意: 在给定01串中,问能分割成多少个子串?每个子串只有一个1.
dp
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a))
const int maxn=;
const int mod=1e9+; ll dp[];
int n;
int a[]; int main()
{
while(~scanf("%d",&n))
{
clc(dp,);
for(int i=;i<n;i++)
cin>>a[i];
dp[]=;
for(int i=;i<=n;i++)
{
ll s=;
for(int j=i-;j>=;j--)
{
s+=a[j];
if(s==)
dp[i]+=dp[j];
}
}
cout<<dp[n]<<endl;
}
return ;
}
codeforces 617B Chocolate的更多相关文章
- Codeforces 617B:Chocolate(思维)
题目链接http://codeforces.com/problemset/problem/617/B 题意 有一个数组,数组中的元素均为0或1 .要求将这个数组分成一些区间,每个区间中的1的个数均为1 ...
- Codeforces 490D Chocolate
D. Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- CodeForces 598E Chocolate Bar
区间DP预处理. dp[i][j][k]表示大小为i*j的巧克力块,切出k块的最小代价. #include<cstdio> #include<cstring> #include ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #310 (Div. 1) C. Case of Chocolate set
C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...
- Educational Codeforces Round 1 E. Chocolate Bar 记忆化搜索
E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/prob ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- Educational Codeforces Round 1 E. Chocolate Bar dp
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memo ...
- Codeforces 689C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes inpu ...
随机推荐
- express 3.0.x 中默认不支持layout.ejs的解决方法
1.第一种方法用include 用<% include 模板名(可不加.ejs) %>的写法,具体如下 <% include header %> //套用布局拆成两部分 hea ...
- Android 获取JSP或ASP的sessionId(Cookie)
如果使用的是httpClient: try { HttpResponse response = HttpUtil.httpClient.execute(new HttpGet(url)); Heade ...
- BZOJ 3533 sdoi 2014 向量集
设(x,y)为Q的查询点,分类讨论如下:1.y>0: 最大化a*x+b*y,维护一个上凸壳三分即可 2.y<0:最大化a*x+b*y 维护一个下凸壳三分即可 我们考虑对时间建出一棵线段 ...
- [itint5]完全二叉树节点个数的统计
http://www.itint5.com/oj/#4 这题是利用完全二叉树的性质计算节点数目.那么是通过比较左右子树的最左结点的高度来看那边是满的,然后递归计算. //使用getLeftChildN ...
- Struts-2.3.24.1官方例子-struts2-blank
一.配置文件 1.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id=&qu ...
- linux编译注解
Linux kernel release 3.x <http://kernel.org/> These are the release notes for Linux version 3. ...
- A9逻辑编译问题
root@phone-desktop:~# cd '/opt/BARE/01led' root@phone-desktop:/opt/BARE/01led# makearm-linux-gnueabi ...
- 在XML里的XSD和DTD以及standalone的使用2----具体使用详解
如何定义XSD并在XML中使用XSD 同时XSD可以对XML中的格式进行约束,当约束失败时给出提示. 下面以下使用VS2010为平台进行演示. 1.新建一个项目,然后在项目中添加xml架构文件(.xs ...
- Where is Vasya?
Where is Vasya? Vasya stands in line with number of people p (including Vasya), but he doesn't know ...
- Complete The Pattern #1
Complete The Pattern #1 Task: You have to write a function pattern which creates the following patte ...