题目

给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。

输入格式

第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度

输出格式

所构成不重复矩形的个数

输入样例

8

1

2

2

3

1

1

3

3

输出样例

3

解释

N<= 20

题解

四个点abcd能构成矩形,当且仅当

弧ab=弧cd 且 弧bc=弧ad

顺序枚举判断一下就好了

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u]; k != -1; k = ed[k].nxt)
using namespace std;
const int maxn = 25,maxm = 100005,INF = 1000000000;
inline int RD(){
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57) {if (c == '-') flag = -1; c = getchar();}
while (c >= 48 && c <= 57) {out = (out << 1) + (out << 3) + c - '0'; c = getchar();}
return out * flag;
}
int d[maxn][maxn],n,A[maxn],tot = 0,ans = 0;
int main(){
n = RD();
REP(i,n) tot += (A[i] = RD());
REP(i,n) A[i] += A[i - 1];
REP(i,n) for (int j = i + 1; j <= n; j++)
d[i][j] = A[j - 1] - A[i - 1];
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
for (int k = j + 1; k <= n; k++)
for (int l = k + 1; l <= n; l++)
if (d[i][j] == d[k][l] && d[j][k] == (tot - d[i][l]))
ans++;
printf("%d\n",ans);
return 0;
}

BZOJ1800 [Ahoi2009]fly 飞行棋 【枚举】的更多相关文章

  1. bzoj1800: [Ahoi2009]fly 飞行棋(乱搞)

    1800: [Ahoi2009]fly 飞行棋 题目:传送门 题解: 大水题,早上签个到 没什么好说的...搞个前缀和,算个周长... 周长为奇数肯定误解啊废话QWQ 那么看到n<=20,还不暴 ...

  2. BZOJ 1800: [Ahoi2009]fly 飞行棋( 枚举 )

    O(N2)算出有x条直径然后答案就是x(x-1)/2...这个数据范围是闹哪样! ----------------------------------------------------------- ...

  3. bzoj千题计划174:bzoj1800: [Ahoi2009]fly 飞行棋

    http://www.lydsy.com/JudgeOnline/problem.php?id=1800 圆上两条直径构成矩形的对角线 #include<cstdio> using nam ...

  4. bzoj1800[Ahoi2009]fly 飞行棋 暴力枚举

    找了道bzoj的水题,千年难得一遇. 建议初学者做做,然而我个蒟蒻初学时应该A不了..... < http://www.lydsy.com/JudgeOnline/problem.php?id= ...

  5. 【枚举】bzoj1800 [Ahoi2009]fly 飞行棋

    暴力枚举. #include<cstdio> #include<algorithm> using namespace std; ],sum[],half,ans; int qu ...

  6. BZOJ1800 [Ahoi2009]fly 飞行棋 其他

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1800 题意概括 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请 ...

  7. BZOJ1800 [Ahoi2009]fly 飞行棋

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  8. bzoj 1800: [Ahoi2009]fly 飞行棋 暴力

    1800: [Ahoi2009]fly 飞行棋 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline ...

  9. BZOJ 1800: [Ahoi2009]fly 飞行棋【思维题,n^4大暴力】

    1800: [Ahoi2009]fly 飞行棋 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1689  Solved: 1335[Submit][St ...

随机推荐

  1. 【ODT】cf896C - Willem, Chtholly and Seniorious

    仿佛没用过std::set Seniorious has n pieces of talisman. Willem puts them in a line, the i-th of which is ...

  2. lintcode_69_二叉树的层次遍历

    二叉树的层次遍历   描述 笔记 数据 评测 给出一棵二叉树,返回其节点值的层次遍历(逐层从左往右访问) 您在真实的面试中是否遇到过这个题? Yes 哪家公司问你的这个题? LinkedIn Airb ...

  3. tomcat7下载地址

    tomcat7下载地址:https://tomcat.apache.org/download-70.cgi

  4. VIM安装YCM插件

    折腾了两天,终于好了 1.配置VIM (1)下载相关插件 sudo apt-get install git sudo apt-get install build-essential cmake sud ...

  5. POJ:1703-Find them, Catch them(并查集好题)(种类并查集)

    Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 49867 Accepted: 153 ...

  6. [Hdu4825]Xor Sum(01字典树)

    Description Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问 ...

  7. Spark 源码阅读——任务提交过程

    当我们在使用spark编写mr作业是,最后都要涉及到调用reduce,foreach或者是count这类action来触发作业的提交,所以,当我们查看这些方法的源码时,发现底层都调用了SparkCon ...

  8. 1,MongoDB简介和安装

    一.初识MongoDB MongoDB 是一个基于分布式文件存储的数据库.由 C++ 语言编写.旨在为 WEB 应用提供可扩展的高性能数据存储解决方案. MongoDB 是一个介于关系数据库和非关系数 ...

  9. 3611: [Heoi2014]大工程

    3611: [Heoi2014]大工程 链接 分析: 树形dp+虚树. 首先建立虚树,在虚树上dp. dp:sum[i]为i的子树中所有询问点之间的和.siz[i]为i的子树中有多少询问点,mn[i] ...

  10. android apk瘦身之 图片压缩 tinypng

    参考地址: http://blog.csdn.net/jy692405180/article/details/52409369 http://www.tuicool.com/articles/BraI ...