617B Codeforces - Chocolate


617B Codeforces - Chocolate




Solution in C++

#include <bits/stdc++.h>

using namespace std;

long long int n,sol=1,flag,ons,t,ze=1;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(i==n-1 && t==0)break;
        if(ons==0 && t==0)continue;
        if(t==1){ons++;flag=1;sol*=ze;ze=1;}
        else {flag=0;ze++;}
    }
         if(ons==1)sol=1;
    else if(ons==0)sol=0;
    cout<<sol;
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق