-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChocolate.java
More file actions
41 lines (33 loc) · 834 Bytes
/
Chocolate.java
File metadata and controls
41 lines (33 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class Chocolate
{
public static void main( String[] args )
{
Scanner s = new Scanner( System.in );
int n =Integer.parseInt( s.nextLine() );
long ways =1;
long count=1;
boolean started = false;
for(int i=0;i<n;i++)
{
//System.out.println( s.nextInt() );
int piece = s.nextInt();
if(started && piece==0)
{
count++;
}
if(started && piece==1)
{
ways*=count;
count=1;
}
if(piece==1)
{
started = true;
}
}
if(started==false)
ways=0;
System.out.println( ways );
}
}