BZOJ 1800: [Ahoi2009]fly 飞行棋【暴力】
Description
给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。
Input
第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度
Output
所构成不重复矩形的个数
Sample Input
8
1
2
2
3
1
1
3
3
Sample Output
3
HINT
N<= 20
思路:唔 N<=20 逗我呢TUT
#include<cstdio>
#include<string.h>
#include<iostream>
#include<algorithm>
#define maxn 400009
#define LL long long
using namespace std;
int sum[maxn],a[maxn];
int main()
{
int n,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum[i]+=sum[i-1]+a[i];
}
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(sum[l]-sum[j]==(sum[n]>>1) && sum[l]-sum[k]==sum[j]-sum[i])
{
ans++;
}
}
}
}
}
printf("%d\n",ans);
return 0;
}
BZOJ 1800: [Ahoi2009]fly 飞行棋【暴力】的更多相关文章
- bzoj 1800: [Ahoi2009]fly 飞行棋 暴力
1800: [Ahoi2009]fly 飞行棋 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline ...
- BZOJ 1800: [Ahoi2009]fly 飞行棋【思维题,n^4大暴力】
1800: [Ahoi2009]fly 飞行棋 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1689 Solved: 1335[Submit][St ...
- BZOJ 1800: [Ahoi2009]fly 飞行棋( 枚举 )
O(N2)算出有x条直径然后答案就是x(x-1)/2...这个数据范围是闹哪样! ----------------------------------------------------------- ...
- bzoj 1800 [Ahoi2009]fly 飞行棋——模拟
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1800 原来只想到一个弧是一条边. 然后发现不是.差点不会做.经Zinn提醒,不用枚举那条边由 ...
- BZOJ 1800 [Ahoi2009]fly 飞行棋
题目链接 思路 终于有一道自己想出来的题了,开心. 因为是矩形,一定有直角,所以考虑直径,之后由于矩形对角线是两条直径,所以考虑组合数. 直径有n条,矩形有c(n,2)个. #include<i ...
- bzoj 1800: [Ahoi2009]fly 飞行棋【枚举】
在圆里所以没有平行四边形,n^4枚举点即可 #include<iostream> #include<cstdio> using namespace std; const int ...
- BZOJ——T 1800: [Ahoi2009]fly 飞行棋
Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1767 Solved: 1395[Submit][Status][Discuss] Descripti ...
- bzoj1800[Ahoi2009]fly 飞行棋 暴力枚举
找了道bzoj的水题,千年难得一遇. 建议初学者做做,然而我个蒟蒻初学时应该A不了..... < http://www.lydsy.com/JudgeOnline/problem.php?id= ...
- 1800: [Ahoi2009]fly 飞行棋
#include<cstdio> #include<iostream> using namespace std; ],n,ans; int main() { scanf(&qu ...
随机推荐
- Invalid bound statement (not found): com.ros.dao.LogMapper.insert
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ros.dao.LogMapp ...
- Could not load OpenSSL解决
问题 Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in you ...
- vue 不支持 数组Array,只支持get set push,但是正是做tab的时候,用到splice,就都不好用了,最后用v-if,从新渲染 完美解决
vue 不支持 数组Array,只支持get set push,但是正是做tab的时候,用到splice,就都不好用了,最后用v-if,从新渲染 完美解决
- sql server 处理分母为空
SP 前面加下面设置,会忽略错误结果 直接返回null 不会导致SP 失败 SET ANSI_WARNINGS OFFSET ARITHABORT OFFSET ARITHIGNORE ON
- react native在xcode真机调试ios
1修改URL地址:打开项目目录下的AppDelegate.m文件,修改里面的URL,把localhost改为你的电脑的IP.在Mac系统下,你可以在系统设置/网络里找到电脑的IP地址. 2选择设备:把 ...
- Luogu P3627 抢掠计划
题目传送门 \(Tarjan\)缩点+SPFA最长路 #include<iostream> #include<cstdio> #include<cstring> # ...
- initWithNibName:bundle awakeFromNib 区别
initWithNibName:bundle 定义:is a message sent to a view (or window) controller in order to create the ...
- iOS 面试集锦
是第一篇: 1.Difference between shallow copy and deep copy? 浅复制和深复制的区别? 答案:浅层复制:只复制指向对象的指针,而不复制引用对象本身. 深层 ...
- windows使用文件服务器搭建Git服务器
背景: 1.windows下搭建git服务器. 2.git服务器搭建在局域网文件共享区中. 3.没有复杂的权限控制,文件共享区都有访问权限. 步骤: 1.文件共享区中创建git远程仓库. 2.本地克隆 ...
- 如何优化sql查询
借鉴https://www.cnblogs.com/ssrstm/p/5753068.html和https://www.cnblogs.com/exe19/p/5786806.html 1. 对查询进 ...