Codeforces 21C Stripe 2 slot. The speaker's mother tongue is definitely not English.

Source: Internet
Author: User

Codeforces 21C Stripe 2 slot. The speaker's mother tongue is definitely not English.

Sum = sigma num [I] (1 <= I <= n ).

S [I] = sigam num [j] (1 <= j <= I ).

Find all the values that meet s [I] * 2 = sum-s [I], s [I] = 2 * (sum-s [I]). Then accumulate the enumerated values.

Slot, but the meaning clearly indicates that positive interge is required for each piece.

However, this restriction is enough.

#include #include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        #include 
         
          #include 
          
           #pragma comment(linker, "/STACK:1024000000");#define EPS (1e-6)#define _LL long long#define ULL unsigned long long#define LL __int64#define INF 0x3f3f3f3f#define Mod 1000000007/** I/O Accelerator Interface .. **/#define g (c=getchar())#define d isdigit(g)#define p x=x*10+c-'0'#define n x=x*10+'0'-c#define pp l/=10,p#define nn l/=10,ntemplate
           
             inline T& RD(T &x){ char c; while(!d); x=c-'0'; while(d)p; return x;}template
            
              inline T& RDD(T &x){ char c; while(g,c!='-'&&!isdigit(c)); if (c=='-') { x='0'-g; while(d)n; } else { x=c-'0'; while(d)p; } return x;}inline double& RF(double &x) //scanf("%lf", &x);{ char c; while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.') { x=0; double l=1; while(d)nn; x*=l; } else { x='0'-c; while(d)n; if(c=='.') { double l=1; while(d)nn; x*=l; } } else if(c=='.') { x=0; double l=1; while(d)pp; x*=l; } else { x=c-'0'; while(d)p; if(c=='.') { double l=1; while(d)pp; x*=l; } } return x;}#undef nn#undef pp#undef n#undef p#undef d#undef gusing namespace std;LL num[100010];LL ans[2][100010] = {{0},{0}};LL sum[2][100010] = {{0},{0}};LL dis[100010] = {0};int mark[2][100010] = {{0},{0}};int main(){ int n; scanf("%d",&n); int i; for(i = 1;i <= n; ++i) scanf("%I64d",&num[i]); for(i = 1;i <= n; ++i) sum[0][i] = sum[0][i-1] + num[i]; for(i = n;i >= 1; --i) sum[1][i] = sum[1][i+1] + num[i]; for(i = 1;i <= n; ++i) ans[0][i] = ans[0][i-1] + (num[i] >= 0 ? 1 : 0); for(i = n;i >= 1; --i) ans[1][i] = ans[1][i+1] + (num[i] >= 0 ? 1 : 0); LL S = sum[0][n]; for(i = 1;i <= n; ++i) if(sum[0][i]*2 == S-sum[0][i] ) mark[0][i] = 1; for(i = n;i >= 1; --i) if(sum[1][i]*2 == S-sum[1][i]) mark[1][i] = 1; for(i = 1;i <= n; ++i) dis[i] = dis[i-1] + mark[0][i]; LL anw = 0; for(i = 2;i <= n; ++i) if(mark[1][i]) anw += dis[i-2]; printf("%I64d\n",anw); return 0;}
            
           
          
         
       
      
     
    
   
  
 

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: info-contact@alibabacloud.com 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.