codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

617B.md (1520B)


      1 Source: https://codeforces.com/problemset/problem/617/B
      2 
      3 B. Chocolate
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 Input
     28 
     29 The first line of the input contains integer *n* (1 ≤ *n* ≤ 100) — the number of pieces in the chocolate bar.
     30 
     31 The second line contains *n* integers *a**i* (0 ≤ *a**i* ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.
     32 
     33 Output
     34 
     35 Print the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 3  
     43 0 1 0
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 1
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 5  
     56 1 0 1 0 1
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 4
     63 ```
     64 
     65 Note
     66 
     67 In the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.
     68 
     69 In the second sample you can break the bar in four ways:
     70 
     71 10|10|1
     72 
     73 1|010|1
     74 
     75 10|1|01
     76 
     77 1|01|01