Bzoj 1800: [Ahoi2009]fly Flight chess violence

Source: Internet
Author: User

1800: [Ahoi2009]fly flying Chess

Time Limit:1 Sec

Memory limit:256 MB

Topic Connection http://www.lydsy.com/JudgeOnline/problem.php?id=1800
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 Input8
1
2
2
3
1
1
3
3

Sample Output

3HINT

n<= 20

Test instructions

Exercises

The data range is only 20, then the direct violence is good ~

Code:

//Qscqesze#pragmaComment (linker, "/stack:1024000000,1024000000")#include<cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<bitset>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 40#defineMoD 1001#defineEPS 1e-9#definePi 3.1415926intNum;//const int INF=0X7FFFFFFF;Constll inf=999999999; inline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//*************************************************************************************intA[MAXN];intMain () {intn=read ();  for(intI=1; i<=n;i++) A[i]=read (), a[i]+=a[i-1]; intAns =0;  for(intI=1; i<=n;i++)     for(intj=i+1; j<=n;j++)     for(intk=j+1; k<=n;k++)     for(intt=k+1; t<=n;t++)        if(a[j]-a[i]==a[t]-a[k]&& (a[n]+a[i]-a[t]) ==a[k]-A[j]) ans++; printf ("%d\n", ans);}

Bzoj 1800: [Ahoi2009]fly Flight chess violence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.