zoukankan      html  css  js  c++  java
  • 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

    题意

    题解:

    数据范围只有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
    ",ans);
    }
  • 相关阅读:
    python中创建函数和调用函数
    python中函数的参数
    python 函数中的关键字参数
    python中创建集合
    python中函数文档
    python中函数形式参数、实际参数、位置参数、关键字参数
    python中不可变集合
    我是谁?(程序员版)
    《林阴小路》疏辨
    用户接口常用术语英语德语对照
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4798969.html
Copyright © 2011-2022 走看看