B. Chocolate
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.

You are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't.

Please note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.

Input

The first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar.

The second line contains n integers ai (0 ≤ ai ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.

Output

Print the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.

Sample test(s)
Input
3
0 1 0
Output
1
Input
5
1 0 1 0 1
Output
4
Note

In the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.

In the second sample you can break the bar in four ways:

10|10|1

1|010|1

10|1|01

1|01|01

题意 :一段01串 分割成段 每段只能有一个1 问一段串有多少种分割方式

题解:每两个1之间0的个数增加一的乘积

#include<bits/stdc++.h>
#define LL __int64
using namespace std;
LL n,l;
LL ans,k,flag;
int main()
{ l=0;
ans=1;
k=0;
scanf("%I64d",&n);
for(int i=1; i<=n; i++)
{
scanf("%I64d",&flag);
if(l)
{
k++;
if(flag)
{
ans*=k;
k=0;
}
}
if(flag)
l=1;
}
ans*=l;
printf("%I64d\n",ans);
}

  

Codeforces Round #340 (Div. 2)B的更多相关文章

  1. [Codeforces Round #340 (Div. 2)]

    [Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...

  2. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 莫队算法

    E. XOR and Favorite Number 题目连接: http://www.codeforces.com/contest/617/problem/E Descriptionww.co Bo ...

  3. Codeforces Round #340 (Div. 2) C. Watering Flowers 暴力

    C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerb ...

  4. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  5. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  6. Codeforces Round #340 (Div. 2) D. Polyline 水题

    D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...

  7. 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)

    题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...

  8. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 【莫队算法 + 异或和前缀和的巧妙】

    任意门:http://codeforces.com/problemset/problem/617/E E. XOR and Favorite Number time limit per test 4 ...

  9. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number —— 莫队算法

    题目链接:http://codeforces.com/problemset/problem/617/E E. XOR and Favorite Number time limit per test 4 ...

  10. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number (莫队)

    题目链接:http://codeforces.com/contest/617/problem/E 题目大意:有n个数和m次查询,每次查询区间[l, r]问满足ai ^ ai+1 ^ ... ^ aj ...

随机推荐

  1. Codeforces-A. Shortest path of the king(简单bfs记录路径)

    A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input s ...

  2. TW实习日记:第23天

    主要的项目已经在修改一些细节以提高用户体验的阶段了,所以并不是太忙,主要就是对样式和一些细节修修改改.然后下午帮助同事的新项目做了一个功能点,主要就是调通接口就行,因为参数巨多,所以总要和网端那边的后 ...

  3. 网页性能管理详解:浅谈chrome-Timeline及window.requestAnimationFrame()方法

    你遇到过性能很差的网页吗? 这种网页响应非常缓慢,占用大量的CPU和内存,浏览起来常常有卡顿,页面的动画效果也不流畅. 你会有什么反应?我猜想,大多数用户会关闭这个页面,改为访问其他网站.作为一个开发 ...

  4. 【MFC】学习与问题整合

    需要源码联系邮件:kangxlchn@163.com 1.新建一个MFC工程(基于对话框) 环境:vs2017 统统NEXT 新建完成后打开MFCPrj.cpp文件 打开类试图 每创建一个MFC项目, ...

  5. HDU 2489 Minimal Ratio Tree(暴力+最小生成树)(2008 Asia Regional Beijing)

    Description For a tree, which nodes and edges are all weighted, the ratio of it is calculated accord ...

  6. Alpha阶段中间产物——Thunder团队

    Part One 版本控制 git地址:https://git.coding.net/lick468/iReader.git Part Two 软件功能说明书 相关链接:http://www.cnbl ...

  7. 学霸系统ui部分软件发布说明

    一.版本新功能 1.搜索主页按钮 在学长的版本中,要想进入搜索主页,方法只有一个,就是在问答搜索结果页中点击链接进入搜索主页,这就使得用户很不方便.我们在学霸系统的主页增加了一个链接按钮,方便用户能够 ...

  8. Median of Two Sorted Arrays(hard)

    题目要求: 有两个排序的数组nums1和nums2分别为m和n大小. 找到两个排序数组的中位数.整体运行时间复杂度应为O(log(m + n)). 示例: 我的方法: 分别逐个读取两个数组的数,放到一 ...

  9. CNN之间的计算

    参考内容 1.网易云课堂微专业——深度学习—04第一周:http://mooc.study.163.com/smartSpec/detail/1001319001.htm 2.CNN基础介绍:http ...

  10. django为model设置表名

    class redis_data(models.Model):     class Meta:         db_table='redis_data'     key=models.CharFie ...