zoukankan      html  css  js  c++  java
  • [luogu2165 AHOI2009] 飞行棋 (枚举)

    传送门

    Description

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

    Input

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

    Output

    所构成不重复矩形的个数

    Sample Input

    8
    1
    2
    2
    3
    1
    1
    3
    3

    Sample Output

    3

    HINT

    N<=20

    Solution

    每两组间隔为半周长的点对都能组成矩形(相当于两直径)
    暴力枚举即可(n才20qwq)

    Code

    //By Menteur_Hxy
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    int n,ans;
    int da[50];
    
    int main() {
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++) {
    		scanf("%d",&da[i]);
    		da[i]+=da[i-1];
    	}
    	int hc=da[n]/2;
    	for(int i=1;i<=n;i++)
    		for(int j=1;j<i;j++)
    			if(da[i]-da[j]==hc) ans++;
    	printf("%d",ans*(ans-1)/2);
    	return 0;
    }
    
    版权声明:本文为博主原创文章,未经博主允许不得转载。 博主:https://www.cnblogs.com/Menteur-Hxy/
  • 相关阅读:
    事务
    Spring核心之IOC&反射
    jquery中的$().each,$.each的区别
    [转载]tail No space left on device
    nginx apache负载均衡测试
    阿里云配置nginx+php+mysql
    nginx xxx.conf
    [转载]How To Install Nginx And PHP-FPM On CentOS 6 Via Yum
    安装memcached
    安装配置nfs
  • 原文地址:https://www.cnblogs.com/Menteur-Hxy/p/9374847.html
Copyright © 2011-2022 走看看