Guest User

Untitled

a guest
Jan 23rd, 2016
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     int prev = -1;
  9.     long long result = 0;
  10.     for (int i = 0; i < n; i++) {
  11.         int v;
  12.         cin >> v;
  13.         if (v == 1) {
  14.             if (prev == -1) {
  15.                 result = 1;
  16.             } else {
  17.                 result *= i - prev;
  18.             }
  19.             prev = i;
  20.         }
  21.     }
  22.  
  23.     cout << result << endl;
  24. }
Add Comment
Please, Sign In to add comment