• Good array (perfect)


    Description


    Smart likes to use arrays. Today, he needs your help to complete a difficult task.
    If for each non-empty sub-array of the array (A) (a sub-array is an array consisting of several consecutive elements selected from the value (A)), if the sum of all the elements of the sub-array is not equal to zero, it is called "Perfect Array". For example, the array ({−1,2,−3}) is "Perfect Array" because all its sub-arrays ({−1}), ({− 1, 2}) , ({− 1, 2, -3}), ({2}), ({2, -3}), and the sum of the elements of ({-3}) are all non-zero. However, the array ({−1, 2, −1, −3}) is not "Perfect Array" because the elements of its subarray ({−1, 2, −1}) The sum is equal to 0.
    Your task is to help Smart calculate the number of "Perfect Array" in the non-empty sub-array of (A) for a given array (A).

    Format


    Input

    The first line contains an integer (n), which represents the length of the array (A).
    The second line contains (n) integers (A_1, A_2, cdots, A_n) for the elements of the array (A).

    Output

    Only one line of the output contains an integer, indicating that the non-empty sub-array of the array (A) is the number of "Perfect Array".

    Sample


    Input

    3
    1 2 -3
    

    Output

    5
    

    Sample Explanation

    Sub-array ({−1}) of array ({1, 2, -3}), ({− 1, 2}), ({− 1, 2, -3}), ({2}), ({2, -3}), ({-3}) is "Perfect Array", but the sub-array ({1, 2, −3}) is not "Perfect Array".

    Hint


    (50\%) data: (n le 1000);
    Data for (100\%): (1 le n le 2 imes 10^5), (-10^9 le A_i le 10^9).

    Sample Code


    Code is not available!
    
  • 相关阅读:
    【Jenkins】jenkins 配置腾讯企业邮箱
    Monkey 用户指南(译)
    Windows,easygui 安装
    python笔记:list--pop与remove的区别
    递归--Java_汉诺塔
    appium安装 For windows
    【web开发--js学习】functionName 如果是一个属性值,函数将不会被调用
    python爬取煎蛋网图片
    pv&pvc
    docker
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13812563.html
Copyright © 2020-2023  润新知