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 ...
随机推荐
- Educational Codeforces Round 11
A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...
- uva 10271
DP 状态转移方程 dp[i][j] = min(dp[i-1][j], dp[i-2][j-1] + w)) dp[i][j] 指的是前i个筷子组成j组所花费的最小值 考虑第i个筷子是否参与第j组 ...
- 用CodeViz绘制函数调用关系图(call graph)
CodeViz是<Understanding The Linux Virtual Memory Manager>(at Amazon,下载地址在页尾)的作者 Mel Gorman 写的一款 ...
- [LeetCode]Divide Two Integer
Divide two integers without using multiplication, division and mod operator. 思考:位运算.AC的时候真的想说一句“尼玛.. ...
- codeforces #313 div1 E
首先我们要注意到一个事情 如果一个灯塔向左覆盖,那么比他小的某个灯塔如果向左覆盖的端点大于当前塔向左覆盖的端点,他一定向右覆盖 对于当前灯塔向右覆盖也是同理 那么我们只需要记录当前覆盖到的端点就可以完 ...
- PHP的执行原理/执行流程
http://www.cnblogs.com/hongfei/archive/2012/06/12/2547119.html 更深入的学习和了解可以查看下面: 风雨的博客http://www.laru ...
- Fibonacci sequence 求余数
#include <iostream> using namespace std; int f(int n); int main() { int n; cin>>n; doubl ...
- Retrofit初识
Retrofit Retrofit是一套RESTful架构的Android(Java)客户端实现,基于注解,提供JSON to POJO(Plain Ordinary Java Object,简单Ja ...
- 修改VMware Workstation 界面语言
修改方法 我安装的VMware版本是10,找到VMware安装目录,我的是C:\Program Files\VMware\VMware Workstation\messages,里面有ja和zh-cn ...
- python学习笔记八--动态类型
一.变量,对象,引用: 1. 变量: 2. 对象:均包含了一个头部信息,有以下两部分内容 a.对象的数据类型, b.引用计数器:纪录当前引用货指向该对象的数量,一旦计数器被清零,该对象的内存空间就会被 ...