zoukankan      html  css  js  c++  java
  • BZOJ1800: [Ahoi2009]fly 飞行棋

    1800: [Ahoi2009]fly 飞行棋

    Time Limit: 10 Sec  Memory Limit: 64 MB
    Submit: 773  Solved: 628
    [Submit][Status]

    Description

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

    Input

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

    Output

    所构成不重复矩形的个数

    Sample Input

    8
    1
    2
    2
    3
    1
    1
    3
    3


    Sample Output

    3

    HINT

    N<= 20

    Source

    题解:

    大暴力术之术!

    四个点构成矩形需要满足两个条件:

    1.对边相等

    2.对角线为直径

    代码:

     1 var tot,i,j,k,l,n,ans,x:longint;
     2     a:array[0..25] of longint;
     3 procedure init;
     4  begin
     5    readln(n);
     6    a[0]:=0;
     7    for i:=1 to n do begin readln(x);a[i]:=a[i-1]+x;end;
     8  end;
     9 procedure main;
    10  begin
    11    tot:=a[n];
    12    for i:=1 to n do
    13     for j:=i+1 to n do
    14      for k:=j+1 to n do
    15       for l:=k+1 to n do
    16        if (a[j]-a[i]=a[l]-a[k]) and (tot-(a[l]-a[j])=a[k]-a[i]) then inc(ans);
    17    writeln(ans);
    18  end;
    19 
    20 begin
    21  assign(input,'input.txt');assign(output,'output.txt');
    22  reset(input);rewrite(output);
    23  init;
    24  main;
    25  close(input);close(output);
    26 end.   
    View Code
  • 相关阅读:
    使用了Theme但是没有效果问题
    4.0 流量控制preference
    android sdk国内目录http://mirrors.neusoft.edu.cn/android/repository/
    xmpp push篇一 广播消息
    cursorfilter
    android 特效UI实现
    Android四大组件一----Activity
    net user命令
    sql2005如何附加数据库
    sql2005中如何启用SA账号
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/3910281.html
Copyright © 2011-2022 走看看