20分钟一遍AC,大水题,我的算法比较复杂,但是好理解,就是找可以凑出来一半周长的点来暴力枚举就行了。

题干:

Description
给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。
Input
第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度
Output
所构成不重复矩形的个数
Sample Input Sample Output

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
#define duke(i,a,n) for(int i = a;i <= n;i++)
#define lv(i,a,n) for(int i = a;i >= n;i--)
#define clean(a) memset(a,0,sizeof(a))
const int INF = << ;
typedef long long ll;
typedef double db;
template <class T>
void read(T &x)
{
char c;
bool op = ;
while(c = getchar(), c < '' || c > '')
if(c == '-') op = ;
x = c - '';
while(c = getchar(), c >= '' && c <= '')
x = x * + c - '';
if(op) x = -x;
}
template <class T>
void write(T x)
{
if(x < ) putchar('-'), x = -x;
if(x >= ) write(x / );
putchar('' + x % );
}
int len[][];
int a[];
int n,tot = ,ans = ;
queue <int> qu;
void work(int x,int k)
{
duke(i,,k - )
{
int s = len[x][i];
duke(j,k + ,n)
{
if(len[x][j] - len[x][k] == s)
{
ans++;
}
}
}
}
int main()
{
read(n);
duke(i,,n)
{
read(a[i]);
a[i + n] = a[i];
tot += a[i];
}
tot /= ;
duke(i,,n)
{
int ok = ;
duke(j,,n)
{
len[i][j] = len[i][j - ] + a[i + j - ];
if(len[i][j] == tot)
{
ok = ;
}
}
if(ok == )
qu.push(i);
}
while(!qu.empty())
{
int x = qu.front();
int k;
duke(i,,n)
{
if(len[x][i] == tot)
{
k = i;
break;
}
}
work(x,k);
qu.pop();
}
printf("%d\n",ans / );
return ;
}
/*
8
1
2
2
3
1
1
3
3
*/

B1800 [Ahoi2009]fly 飞行棋 数学模拟的更多相关文章

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

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

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

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

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

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

  4. BZOJ_1800_[Ahoi2009]fly 飞行棋_乱搞

    BZOJ_1800_[Ahoi2009]fly 飞行棋_乱搞 Description 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请找出这些点中有没有可以围成矩形的 ...

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

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

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

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

  7. BZOJ1800 [Ahoi2009]fly 飞行棋

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

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

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

  9. 1800: [Ahoi2009]fly 飞行棋

    #include<cstdio> #include<iostream> using namespace std; ],n,ans; int main() { scanf(&qu ...

随机推荐

  1. 【PL/SQL】九九乘法口诀表

    --输出屏幕信息 SET serveroutput ON; --打印口诀表 DECLARE V_NUMBER1 ); --外层循环变量 V_NUMBER2 ); --内层循环变量 BEGIN .. - ...

  2. Cookie的实现

    Cookie是web server下发给浏览器的任意的一段文本,在后续的http 请求中,浏览器会将cookie带回给Web Server.同时在浏览器允许脚本执行的情况下,Cookie是可以被Jav ...

  3. GeckoWebBrowser设置cookie

    var uri = new Uri("http://www.aa.com"); //often cookies are stored on domain level, so &qu ...

  4. JAR包中读取资源文件

    我们常常在代码中读取一些资源文件(比如图片,音乐,文本等等).在单独运行的时候这些简单的处理当然不会有问题.但是,如果我们把代码打成一个jar包以后,即使将资源文件一并打包,这些东西也找不出来了.看看 ...

  5. netperf使用指南

    1. 介绍: Netperf是由惠普公司开发的,测试网络栈.即测试不同类型的网络性能的benchmark工具,大多数网络类型TCP/UPD端对端的性能,得到网络上不同类型流量的性能参数.Netperf ...

  6. JS练习:显示和隐藏

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. 【模板】非旋转Treap

    Treap,也叫做树堆,是指有一个随机附加域满足堆的性质的二叉搜索树. 如果一棵二叉搜索树插入节点的顺序是随机的,那我们得到的二叉搜索树在大多数情况下是平衡的,期望高度是log(n). 但有些情况下我 ...

  8. flask_model防止循环引用

    1 首先介绍app-model的循环引用 https://www.cnblogs.com/fuzzier/p/7920645.html 2 解决方式 https://www.cnblogs.com/f ...

  9. 手动部署tidb(二进制包)集群

    环境准备 系统:centos7.2 用户:root 主机配置ntp时间同步 主机配置ssh互信 3节点: hostname@ip 部署组件 tidb1@10.70.249.24 PD,TiKV,TiD ...

  10. 树 (p155, 从中序和后续回复二叉树)

    递归求解, You are to determine the value of the leaf node in a given binary tree that is the terminal no ...