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. 【译】x86程序员手册16-5.3联合使用段与分页转换

    5.3 Combining Segment and Page Translation  联合使用段与分页转换 Figure 5-12 combines Figure 5-2 and Figure 5- ...

  2. PHP递归复制文件夹以及传输文件夹到其他服务器。

    项目中需要复制整个文件夹,有时候还需要将整个文件夹传输到远程服务器. 这里就要递归遍历整个文件夹了,想看递归遍历文件夹的代码. function deepScanDir($dir) { $fileAr ...

  3. @RequestMapping参数value和params的区别

    value的值可以是一个url地址的形式或者正则表达式或者rest风格的形式,而params正如其名是参数,访问的时候params的值只能作为参数,不能作为访问的地址,请看下例> value的使 ...

  4. 使用ScriptManager服务器控件前后台数据交互

    前台页面信息: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFor ...

  5. jenkins配置邮件通知

    参考: https://www.cnblogs.com/imyalost/p/8781759.html 谢谢大佬~

  6. * 获取页面参数 * @return 参数打印

    /** * 获取页面参数 * @return 参数打印 */ GetUrlParam: function(paraName) { var url = document.location.toStrin ...

  7. collections、random、hashlib、configparser、logging模块

    collections模块 在内置数据类型(dict.list.set.tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter.deque.defaultdict. ...

  8. 8.2.3 操作MySQL数据库

    Python访问MySQL数据库可以使用MySQLDb模块,该模块主要方法如下: (1)commit():提交事务. (2)rollback():回滚事务. (3)callproc(self,proc ...

  9. 【codeforces 796C】Bank Hacking(用一些技巧来代替multiset)

    [题目链接]:http://codeforces.com/contest/796/problem/C [题意] 给你n个节点,你一开始选择一个节点,然后打掉它,然后与被打掉过的节点相连的节点才能被 打 ...

  10. JavaSE 学习笔记之Object对象(八)

    Object:所有类的直接或者间接父类,Java认为所有的对象都具备一些基本的共性内容,这些内容可以不断的向上抽取,最终就抽取到了一个最顶层的类中的,该类中定义的就是所有对象都具备的功能. 具体方法: ...