B. Chocolate

题目连接:

http://www.codeforces.com/contest/617/problem/D

Descriptionww.co

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 Input

5

1 0 1 0 1

Sample Output

4

Hint

题意

给你n个数字,你可以从数字间切开

然后问你有多少种切法,使得切出来的每一块恰有且仅有一个1

题解:

假如没有1,答案就是0

否则就是间隔中的0的个数+1的累乘

因为你就只能切0周围的空隙,然后根据乘法原则

代码

#include<bits/stdc++.h>
using namespace std; int a[120];
vector<int> E;
int main()
{
int n;scanf("%d",&n);
int flag = 1;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]==1)flag = 0;
}
if(flag)return puts("0");
int cnt = 0;
for(int i=1;i<=n;i++)
{
if(a[i]==1)
{
E.push_back(cnt+1);
cnt = 0;
}
else
cnt++;
}
long long ans = 1;
for(int i=1;i<E.size();i++)
ans = ans * E[i];
cout<<ans<<endl;
}

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

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

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

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

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

  3. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  4. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  5. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  6. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  7. Codeforces Round #340 (Div. 2) B. Chocolate

    题意:一段01串 分割成段 每段只能有一个1 问一段串有多少种分割方式 思路:两个1之间有一个0就有两种分割方式,然后根据分步乘法原理来做. (不过这里有一组0 1 0这种数据的话就不好直接处理,所以 ...

  8. Educational Codeforces Round 13 C. Joty and Chocolate 水题

    C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...

  9. Codeforces Round #338 (Div. 2) A. Bulbs 水题

    A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...

随机推荐

  1. Java IO读写大文件的几种方式及测试

    读取文件大小:1.45G 第一种,OldIO: public static void oldIOReadFile() throws IOException{ BufferedReader br = n ...

  2. linux清空日志文件内容 (转)

    随着系统运行时间越来越长,日志文件的大小也会随之变得越来越大.如果长期让这些历史日志保存在系统中,将会占用大量的磁盘空间.用户可以直接把这些日志文件删除,但删除日志文件可能会造成一些意想不到的后果.为 ...

  3. PreferenceActivity使用方法

              public class MainActivity extends Activity { @Override protected void onCreate(Bundle save ...

  4. HDU5808Price List Strike Back (BestCoder Round #86 E) cdq分治+背包

    严格按题解写,看能不能形成sum,只需要分割当前sum怎么由两边组成就好 #include <cstdio> #include <cstring> #include <c ...

  5. html --- javascript --- div --- 拖拽方块

    当鼠标拖拽的很快时,光标会走出方块,所以把事件注册在了方块的父节点上, 如有疑问请参照:http://blog.csdn.net/a9529lty/article/details/2708171 使用 ...

  6. 浅谈“be practical and realistic”

    一 “实事求是”这个词,一般认为是古人的一种治学观念,后来经咏芝的发明.阐释.以及“应用”,成为“基本思想路线”(具体可参看大学思想政治教科书),被称为“活的灵魂”.这里不想过多地牵扯政治话题,仅就我 ...

  7. 说说Python 中的文件操作 和 目录操作

    我们知道,文件名.目录名和链接名都是用一个字符串作为其标识符的,但是给我们一个标识符,我们该如何确定它所指的到底是常规文件文件名.目录名还是链接名呢?这时,我们可以使用os.path模块提供的isfi ...

  8. 2015-11-02-js

    1.对象 创建方式有两种,一时通过new 后加object构造函数,二是用字面量法, var box=new object(); var box={ name='bokeyuan'; }; 访问对象: ...

  9. Ubuntu安装PostgreSQl

    warrior@pc:~$ sudo apt-get install postgresql-xx-xx #可以使用Tab键进行代码补全 warrior@pc:~$ sudo su postgres # ...

  10. 2 weekend110的HDFS的JAVA客户端编写 + filesystem设计思想总结

    HDFS的JAVA客户端编写  现在,我们来玩玩,在linux系统里,玩eclipse 或者, 即,更改图标,成功 这个,别慌.重新换个版本就好,有错误出错是好事. http://www.eclips ...