[题目链接]

https://codeforces.com/contest/466/problem/C

[算法]

维护序列前缀和 , 枚举中间一段即可 , 详见代码

时间复杂度 : O(N)

[代码]

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + ; int a[MAXN];
long long sum[MAXN]; template <typename T> inline void read(T &x)
{
T f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << ) + (x << ) + c - '';
x *= f;
} int main()
{ int n;
read(n);
for (int i = ; i <= n; i++)
{
read(a[i]);
sum[i] = sum[i - ] + a[i];
}
if (sum[n] % != )
{
printf("0\n");
return ;
}
long long value = sum[n] / , ans = , cnt = ;
for (int i = ; i < n; i++)
{
if (sum[i] != * value)
{
if (sum[i] == value) cnt++;
continue;
}
ans += cnt;
if (sum[i] == value) cnt++;
}
printf("%I64d\n",ans); return ; }

[Codeforces 466C] Number of Ways的更多相关文章

  1. codeforces 466C. Number of Ways 解题报告

    题目链接:http://codeforces.com/problemset/problem/466/C 题目意思:给出一个 n 个数的序列你,问通过将序列分成三段,使得每段的和都相等的分法有多少种. ...

  2. Codeforces - 466C - Number of Ways - 组合数学

    https://codeforces.com/problemset/problem/466/C 要把数据分为均等的非空的三组,那么每次确定第二个分割点的时候把(除此之外的)第一个分割点的数目加上就可以 ...

  3. Codeforces Round #266 (Div. 2) C. Number of Ways

    You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split ...

  4. cf466C Number of Ways

    C. Number of Ways time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. LeetCode 5274. Number of Ways to Stay in the Same Place After Some Steps - Java - DP

    题目链接:5274. 停在原地的方案数 You have a pointer at index 0 in an array of size arrLen. At each step, you can ...

  6. 【leetcode】1269. Number of Ways to Stay in the Same Place After Some Steps

    题目如下: You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 positio ...

  7. 【Codeforces 466C】Number of Ways

    [链接] 我是链接,点我呀:) [题意] 让你把数组分成3个连续的部分 每个部分的和要一样 问你有多少种分法 [题解] 先处理出来num[i] 表示i..n这里面有多少个j 满足aft[j] = af ...

  8. codeforces Hill Number 数位dp

    http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits: ...

  9. codeforces 27E Number With The Given Amount Of Divisors

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

随机推荐

  1. [Python3网络爬虫开发实战] 1.2.3-ChromeDriver的安装

    前面我们成功安装好了Selenium库,但是它是一个自动化测试工具,需要浏览器来配合使用,本节中我们就介绍一下Chrome浏览器及ChromeDriver驱动的配置. 首先,下载Chrome浏览器,方 ...

  2. css3新特性学习系列 -- border

    css3新特性 border属性(border-radius.border-image.box-shadow)详解 1.border-radius  圆角 支持:IE9+ 用法: border-rad ...

  3. centos passwo文件被删除

    错误提示 该问题一般由/etc/passwd被清空,删除,移动,改名等造成,需要通过救援模式恢复,操作步骤如下 真实环境已经解决,这里使用vmware模拟.光盘启动,选择救援模式: 语言选择,键盘布局 ...

  4. java 常用集合类型--以及其特性

    1:集合:   (1) Collection(单列集合)        List(有序,可重复)            ArrayList                底层数据结构是数组,查询快,增 ...

  5. Memcache 分布式存储 【一致性Hash】crc32

    class memcacheHash { private $_node = array(); private $_nodeData = array(); private $_keyNode = 0; ...

  6. 什么是CPU密集型、IO密集型?(转发)

    CPU密集型(CPU-bound) CPU密集型也叫计算密集型,指的是系统的硬盘.内存性能相对CPU要好很多,此时,系统运作大部分的状况是CPU Loading 100%,CPU要读/写I/O(硬盘/ ...

  7. 用java实现二分搜索<算法分析>

    实验目的:1.复习java编程:2.掌握二分搜索技术的基本原理:3.掌握使用java程序进行二分搜索的方法.实验步骤:1.由用户输入5个以上的整数:2.利用二分搜索算法完成对数组的搜索. packag ...

  8. 管理Cookie和Session

    管理Cookie和Session 前言 这几天中,一直再跟漏洞打交道,而在这些漏洞中,出现的最多的就是 Cookie 和 Session 了.这篇文章就简单的介绍一些 Cookie 中最常用的四个属性 ...

  9. 斯特林(Stirling)公式 求大数阶乘的位数

    我们知道整数n的位数的计算方法为:log10(n)+1n!=10^m故n!的位数为 m = log10(n!)+1 lgN!=lg1+lg2+lg3+lg4+lg5+................. ...

  10. M2Crypto

    M2Crypto = Python + OpenSSL + SWIG M2Crypto is a crypto and SSL toolkit for Python. 上面是M2Crypto的READ ...