zoukankan      html  css  js  c++  java
  • bzoj 1800 暴力枚举

    直接暴力枚举四个点,然后判断是否能组成矩形就行了

    注意枚举的点的标号从小到大,保证不重复枚举

    /**************************************************************
        Problem: 1800
        User: BLADEVIL
        Language: Pascal
        Result: Accepted
        Time:0 ms
        Memory:224 kb
    ****************************************************************/
     
    //By BLADEVIL
    var
        n                           :longint;
        sum                         :array[0..21] of longint;
        i, j, k, l                  :longint;
        a, b, c, d                  :longint;
        tot, ans                    :longint;
         
    function min(a,b:longint):longint;
    begin
        if a>b then min:=b else min:=a;
    end;
         
    begin
        read(n);
        for i:=2 to n+1 do read(sum[i]);
        for i:=2 to n+1 do inc(tot,sum[i]);
        for i:=1 to n do sum[i]:=sum[i]+sum[i-1];
        for i:=1 to n do
            for j:=i+1 to n do
                for k:=j+1 to n do
                    for l:=k+1 to n do
                    begin
                        a:=sum[j]-sum[i];
                        a:=min(tot-a,a);
                        b:=sum[k]-sum[j];
                        b:=min(tot-b,b);
                        c:=sum[l]-sum[k];
                        c:=min(c,tot-c);
                        d:=abs(sum[l]-sum[i]);
                        d:=min(d,tot-d);
                        if (a=c) and (b=d) then inc(ans);
                    end;
        writeln(ans);
    end.
  • 相关阅读:
    用户故事——老师
    用户故事——学生
    用户故事——管理员
    WebStorm 2018 最新激活码 license server
    vue cli 4.3.1版本脚手架 新人请看系列
    iviewtable表格数据 录音播放下载
    git修改远程仓库地址
    git上传提交个人心得
    layui 数据拆分 重组数据
    日志
  • 原文地址:https://www.cnblogs.com/BLADEVIL/p/3500879.html
Copyright © 2011-2022 走看看