bzoj 1800: [Ahoi2009]fly 飞行棋

找圆就是矩形对角线(不知道本蒟蒻的垃圾大暴力为什么不对。。)

 1 /*#include<bits/stdc++.h>
 2 #define N 200005
 3 #define LL long long
 4 #define inf 0x3f3f3f3f
 5 #define ls tr[x][0]
 6 #define rs tr[x][1]
 7 using namespace std;
 8 inline int ra()
 9 {
10     int x=0,f=1; char ch=getchar();
11     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
12     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
13     return x*f;
14 }
15 int a[50];
16 int main()
17 {
18     int n=ra(),tot=0,ans=0;
19     for (int i=1; i<=n; i++) a[i]=ra(),tot+=a[i];
20     if (tot%2) {
21         cout<<"0";
22         return 0;
23     }
24     for (int i=n+1; i<=2*n; i++) a[i]=a[i-n];
25     for (int k=1; k<n; k++)
26         for (int i=1; i<=n; i++)
27         {
28             int sum=0;
29             for (int j=i; j<=i+k-1; j++) sum+=a[j];
30             if (2*sum>=tot || (tot-2*sum)%2) break;  //break改成continue就AC2333 
31             int orz=(tot-2*sum)/2,sum1=0;
32             for (int j=i+k; j<=2*n; j++)
33             { 
34                 sum1+=a[j];
35                 if (sum1==orz) 
36                 {
37                     int sum2=0;
38                     for (int l=j+1; l<=2*n; l++)
39                     {
40                         sum2+=a[l];
41                         if (sum2==sum) ans++;
42                         if (sum2>sum) break;
43                     }
44                 }
45                 if (sum1>orz) break;
46             }
47         //    cout<<ans<<"!!";system("pause");
48         }
49     cout<<ans/4;
50     return 0;
51 }*/
52 #include<bits/stdc++.h>
53 #define N 200005
54 #define LL long long
55 #define inf 0x3f3f3f3f
56 #define ls tr[x][0]
57 #define rs tr[x][1]
58 using namespace std;
59 inline int ra()
60 {
61     int x=0,f=1; char ch=getchar();
62     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
63     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
64     return x*f;
65 }
66 int a[50];
67 int main()
68 {
69     int n=ra(),tot=0,ans=0;
70     for (int i=1; i<=n; i++) a[i]=ra(),tot+=a[i];
71     if (tot%2) {
72         cout<<"0";
73         return 0;
74     }
75     for (int i=1; i<=n; i++)
76     {
77         int sum=0;
78         for (int j=i+1; j<=n; j++)
79         {
80             sum+=a[j];
81             if (sum==tot/2) ans++;
82         }
83     }
84     cout<<(ans*(ans-1)>>1);
85     return 0;
86 }

 

posted @ 2017-03-01 08:21  ws_ccd  阅读(137)  评论(0编辑  收藏  举报