zoukankan      html  css  js  c++  java
  • bzoj1800

    fly 飞行棋

     HYSBZ - 1800 

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

    N<= 20

    sol : n4爆枚即可‘

    #include <bits/stdc++.h>
    using namespace std;
    typedef int ll;
    inline ll read()
    {
        ll s=0;
        bool f=0;
        char ch=' ';
        while(!isdigit(ch))
        {
            f|=(ch=='-'); ch=getchar();
        }
        while(isdigit(ch))
        {
            s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
        }
        return (f)?(-s):(s);
    }
    #define R(x) x=read()
    inline void write(ll x)
    {
        if(x<0)
        {
            putchar('-'); x=-x;
        }
        if(x<10)
        {
            putchar(x+'0'); return;
        }
        write(x/10);
        putchar((x%10)+'0');
        return;
    }
    #define W(x) write(x),putchar(' ')
    #define Wl(x) write(x),putchar('
    ')
    const int N=25;
    int n,Dis[N],Qzh[N];
    int main()
    {
        int i,a,b,c,d,ans=0,Sum=0;
        R(n);
        for(i=1;i<=n;i++)
        {
            R(Dis[i]); Qzh[i]=Qzh[i-1]+Dis[i]; Sum+=Dis[i];
        }
        for(a=1;a<=n;a++)
        {
            for(b=a+1;b<=n;b++)
            {
                for(c=b+1;c<=n;c++)
                {
                    for(d=c+1;d<=n;d++)
                    {
                        if(Qzh[b]-Qzh[a]==Qzh[d]-Qzh[c])
                        if(Qzh[c]-Qzh[b]==Sum-Qzh[d]+Qzh[a])
                        ans++;
                    }
                }
            }
        }
        Wl(ans);
        return 0;
    }
    /*
    input
    8
    1
    2
    2
    3
    1
    1
    3
    3
    output
    3
    */
    View Code
  • 相关阅读:
    小程序开发系列(五)悬浮搜索框
    LINQ的连接扩展(左连、右连、全连等)
    小程序开发系列(四)九宫格另一种实现
    python 生成随机图片验证码
    django定时任务小插件
    线程池模块thernd
    python logging 模块记录日志
    django Q条件
    jquery 事件绑定
    jQuery示例
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/11153164.html
Copyright © 2011-2022 走看看