BZOJ1800 [Ahoi2009]fly 飞行棋
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作。
本文作者:ljh2000
作者博客:http://www.cnblogs.com/ljh2000-jump/
转载请注明出处,侵权必究,保留最终解释权!
Description
Input
Output
Sample Input
1
2
2
3
1
1
3
3
Sample Output
HINT
N<= 20
//It is made by ljh2000
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 45;
int n,a[MAXN],tot,sum,ans;
inline int getint(){
int w=0,q=0; char c=getchar(); while((c<'0'||c>'9') && c!='-') c=getchar();
if(c=='-') q=1,c=getchar(); while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;
} inline void work(){
n=getint(); for(int i=1;i<=n;i++) a[i]=getint(),sum+=a[i];
if(sum&1){ printf("0"); return ; } sum>>=1;
for(int i=1,j=1;i<n;i++) { tot+=a[i]; while(tot>sum) tot-=a[j++]; if(tot==sum) ans++; }
printf("%d",ans*(ans-1)/2);
} int main()
{
work();
return 0;
}
BZOJ1800 [Ahoi2009]fly 飞行棋的更多相关文章
- bzoj千题计划174:bzoj1800: [Ahoi2009]fly 飞行棋
http://www.lydsy.com/JudgeOnline/problem.php?id=1800 圆上两条直径构成矩形的对角线 #include<cstdio> using nam ...
- bzoj1800: [Ahoi2009]fly 飞行棋(乱搞)
1800: [Ahoi2009]fly 飞行棋 题目:传送门 题解: 大水题,早上签个到 没什么好说的...搞个前缀和,算个周长... 周长为奇数肯定误解啊废话QWQ 那么看到n<=20,还不暴 ...
- BZOJ1800 [Ahoi2009]fly 飞行棋 其他
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1800 题意概括 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请 ...
- bzoj1800[Ahoi2009]fly 飞行棋 暴力枚举
找了道bzoj的水题,千年难得一遇. 建议初学者做做,然而我个蒟蒻初学时应该A不了..... < http://www.lydsy.com/JudgeOnline/problem.php?id= ...
- 【枚举】bzoj1800 [Ahoi2009]fly 飞行棋
暴力枚举. #include<cstdio> #include<algorithm> using namespace std; ],sum[],half,ans; int qu ...
- BZOJ1800 [Ahoi2009]fly 飞行棋 【枚举】
题目 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形. 输入格式 第一行为正整数N,表示点的个 ...
- bzoj 1800: [Ahoi2009]fly 飞行棋 暴力
1800: [Ahoi2009]fly 飞行棋 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline ...
- BZOJ 1800: [Ahoi2009]fly 飞行棋( 枚举 )
O(N2)算出有x条直径然后答案就是x(x-1)/2...这个数据范围是闹哪样! ----------------------------------------------------------- ...
- BZOJ 1800: [Ahoi2009]fly 飞行棋【思维题,n^4大暴力】
1800: [Ahoi2009]fly 飞行棋 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1689 Solved: 1335[Submit][St ...
随机推荐
- 兼容IE8 input的placeholder的文字显示
if( !('placeholder' in document.createElement('input')) ){ $('input[placeholder],textarea[placeholde ...
- 浏览器渲染引擎,提高css渲染速度。
一.渲染引擎渲染引擎的职责是……渲染,也就是把请求的内容显示到浏览器屏幕上.默认情况下渲染引擎可以显示HTML,XML文档以及图片. 通过插件(浏览器扩展)它可以显示其它类型文档. 二.各种渲染引擎我 ...
- 初识IOS,Label控件的应用。
初识IOS,Label控件的应用. // // ViewController.m // Gua.test // // Created by 郭美男 on 16/5/31. // Copyright © ...
- django 第二天 制作小demo
创建虚拟目录 mkdir ~/virtualenvs mkdir ~/virtualenvs/myprojectenv virtualenv ~/virtualenvs/myprojectenv 激活 ...
- mysql比较时间大小unix_timestamp
使用unix_timestamp方法进行比较,将字符型的时间,转成unix时间戳 select * from t1 where unix_timestamp(time1) > unix_time ...
- HttpsURLConnection 利用keepAlive特性进行优化一例
最近项目中,遇到一个报错: java.lang.OutOfMemoryError: unable to create new native thread 报错的场景是:一个消息的群发,群里总共有50多 ...
- python学习笔记4-正则表达式
import re -- 所有正则表达式相关的功能都包含在re模块中 re.sub() -- 字符串替换 >>> import re >>> s= "10 ...
- 【转】[fix] Wireshark error: There are no interfaces on which a capture can be done. on Mac OS X
I got the following error message when trying to open a network interface for capture using Wireshar ...
- 烂泥:学习centos之快速搭建LNMP环境
本文由秀依林枫提供友情赞助,首发于烂泥行天下 以前在centos下安装软件都是喜欢源码安装,不过昨天因为一个事情需要一个centos 下的LNMP环境.反倒不会搞了,今天特意记录下,以备后续使用. 一 ...
- Android应用架构之Android MVP使用
前两篇已经将Retrofit和RxAndroid应用到了项目中,这篇本打算直接将Dagger2引进项目,但是考虑到整个项目结构,就来个结构整理吧,一起来看看网上炒得火热MVP模式. 说到MVP就不得不 ...