Description
Given a number of points on the circumference, the arc length between the point and the point is known, and the values are positive integers, arranged in a circular order. Please find out if there are any rectangles in these points and hope to find all the non-repeating rectangles in the shortest time.
Input
The first action is an integer n, which represents the number of points, and the next n rows are the individual arc lengths divided by the N points.
Output
The number of non-repeating rectangles that are formed
Sample Input
8
1
2
2
3
1
1
3
3
Sample Output
3
HINT
n<= 20
Idea: Well n<=20 tease me tut
#include <cstdio>
#include <string.h>
#include <iostream>
#include <algorithm>
#define MAXN 400009
#define LL Long Long
using namespace Std;
int SUM[MAXN],A[MAXN];
int main ()
{
int n,ans=0;
scanf ("%d", &n);
for (int i=1;i<=n;i++)
{
scanf ("%d", &a[i]);
Sum[i]+=sum[i-1]+a[i];
}
for (int i=1;i<=n;i++)
{
for (int j=i+1;j<=n;j++)
{
for (int k=j+1;k<=n;k++)
{
for (int l=k+1;l<=n;l++)
{
if (sum[l]-sum[j]== (sum[n]>>1) && Sum[l]-sum[k]==sum[j]-sum[i])
{
ans++;
}
}
}
}
}
printf ("%d\n", ans);
return 0;
}
Bzoj 1800: [Ahoi2009]fly Flight Chess "violence"