CF466C.Number of Ways

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You've got array a[1],a[2],...,a[n]a[1],a[2],...,a[n] , consisting of nn integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.

More formally, you need to find the number of such pairs of indices i,ji,j (2<=i<=j<=n1)(2<=i<=j<=n-1) , that .

输入格式

The first line contains integer nn (1<=n<=5105)(1<=n<=5·10^{5}) , showing how many numbers are in the array. The second line contains nn integers a[1]a[1] , a[2]a[2] , ..., a[n]a[n] (a[i]<=109)(|a[i]|<=10^{9}) — the elements of array aa .

输出格式

Print a single integer — the number of ways to split the array into three parts with the same sum.

输入输出样例

  • 输入#1

    5
    1 2 3 0 3
    

    输出#1

    2
    
  • 输入#2

    4
    0 1 -1 0
    

    输出#2

    1
    
  • 输入#3

    2
    4 1
    

    输出#3

    0
    
首页