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

1800: [Ahoi2009]fly 飞行棋

Time Limit: 1 Sec  

Memory Limit: 256 MB

题目连接

http://www.lydsy.com/JudgeOnline/problem.php?id=1800

Description

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

Input

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

Output

所构成不重复矩形的个数

Sample Input

8

1

2

2

3

1

1

3

3

Sample Output

3

HINT

 N<= 20

《bzoj 1800: [Ahoi2009]fly 飞行棋 暴力》

题意

 

题解:

数据范围只有20,那就直接暴力就好了~

代码:

//qscqesze
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 40
#define mod 1001
#define eps 1e-9
#define pi 3.1415926
int Num;
//const int inf=0x7fffffff;
const ll inf=999999999;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//*************************************************************************************

int a[maxn];
int main()
{
    int n=read();
    for(int i=1;i<=n;i++)
        a[i]=read(),a[i]+=a[i-1];
    int ans = 0;
    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 t=k+1;t<=n;t++)
        if(a[j]-a[i]==a[t]-a[k]&&(a[n]+a[i]-a[t])==a[k]-a[j])
            ans++;
    printf("%d\n",ans);
}

 

    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/4798969.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞