Codeforces 617B Chocolate

Source: Internet
Author: User

Count the number of 0 for each of the two 1, and multiply the numbers by a few +1.

Note two places: will explode int, need to open a long long. All numbers are 0 when the output is 0.

#include <cstdio>#include<cstring>#include<vector>#include<cmath>#include<queue>#include<list>#include<algorithm>using namespacestd;Const intmaxn= -+Ten;intN;intA[maxn];vector<Long Long>v;intMain () {scanf ("%d",&N); Long Longans=0; intfirst=-1, last=-1;  for(intI=1; i<=n; i++) scanf ("%d",&A[i]);  for(intI=1; i<=n; i++)    {        if(A[i]) { first=i;  Break; }    }     for(intI=n; i>=1; i--)    {        if(A[i]) { last=i;  Break; }    }    if(first!=-1) {v.clear (); Long Longnum=0;  for(intI=first; i<=last; i++)        {            if(a[i]==1) {v.push_back (num+1); Num=0; }            if(a[i]==0) num++; }    }    if(v.size () = =0) printf ("0\n"); Else{ans=1;  for(intI=0; I<v.size (); i++) ans=ans*V[i]; printf ("%lld\n", ans); }    return 0;}

Codeforces 617B Chocolate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.