codeforce Number of Ways(暴力)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 500005
using namespace std;
typedef long long LL;
LL prefix[N], suffix[N], num[N];
LL cntSuf[N];
int main(){
int n;
scanf("%d", &n);
for(int i=; i<=n; ++i){
scanf("%lld", &num[i]);
prefix[i]=prefix[i-]+num[i];//前缀和
}
for(int i=n; i>=; --i)
suffix[i]=suffix[i+]+num[i];//后缀和
LL s=prefix[n]/;
if(prefix[n]%!=){
printf("0\n");
return ;
}
LL ans=;
for(int i=; i<=n; ++i)
if(suffix[n-i+]==s) cntSuf[n-i+]=cntSuf[n-i+]+;
else cntSuf[n-i+]=cntSuf[n-i+];
for(int i=; i<=n; ++i)
if(prefix[i]==s) ans+=cntSuf[i+];
printf("%lld\n", ans);
return ;
}
codeforce Number of Ways(暴力)的更多相关文章
- cf466C Number of Ways
C. Number of Ways time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 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 ...
- 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 ...
- 【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 ...
- 10年省赛-Greatest Number (二分+暴力) + 12年省赛-Pick apples(DP) + UVA 12325(暴力-2次枚举)
题意:给你n个数,在里面取4个数,可以重复取数,使和不超过M,求能得到的最大的数是多少: 思路:比赛时,和之前的一个题目很像,一直以为是体积为4(最多选择四次)的完全背包,结果并不是,两两求和,然后二 ...
- Mine Number(搜索,暴力) ACM省赛第三届 G
Mine Number Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Every one once played the gam ...
- Educational Codeforces Round 11 D. Number of Parallelograms 暴力
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...
- codeforce 985A Chess Placing(暴力)
Chess Placing time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces 768 C. Jon Snow and his Favourite Number(思维+暴力)
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后 ...
随机推荐
- ucos操作系统的内核有哪些调度方法
1)时间片轮番调度法 假设系统中有5个任务,T1,T2,T3,T4,T5,这个时候,操作系统为每一个任务分配时间,比如说我们为T1任务分配10毫秒,为T2任务分配20毫秒,为T3任务分配5毫秒,为T4 ...
- photoshop 快速切图
发现一个详细好方法:http://blog.csdn.net/zhangxiaowei_/article/details/42143307 具体如下:
- Awesome C/C++
Awesome C/C++ A curated list of awesome C/C++ frameworks, libraries, resources, and shiny things. In ...
- android 6.0权限判断 音频 拍照 相册
------------------------------------------打开音频权限------------------------------------------------ if ...
- AWVS漏洞测试-02节-添加一个简单的新闻系统
实现一个简单的新闻发布系统 有登录 注册 添加新闻 浏览新闻 评论新闻 新闻列表 这些基本功能 使用asp.net webform 首先是登录页 protected void Button1_Clic ...
- 常用的sql脚本 游标遍历操作
Declare @id int DECLARE cursor_data CURSOR FOR --这里是取得数据源 OPEN cursor_data FETCH FROM cursor_data IN ...
- NSBundle 的理解和 mainBundle
http://www.360doc.com/content/15/0629/10/20918780_481405304.shtml
- std::bind和std::function
std::bind 用于绑定一个函数,返回另外一种调用方式的函数对象 ,可以改变参数顺序 和个数,特别是在多线程的程序中,经常用它将函数进行包装,然后打包发送给工作线程,让工作线程去执行我们的任务. ...
- 自己写的一个Yeoman的Generator-Require-Angularjs
Yeoman是一个常见的工作流,能够很方面的搭建属于自己的脚手架. 这段时间我用闲暇时间写了一个Generator来玩了一下,这个Generator的主要目的是快速建立一个RequireJS+Angu ...
- 那些一目了然的3D地质模型 【转】
http://www.360doc.com/content/16/0830/09/14719766_586950902.shtml