1800: [Ahoi2009]fly flying Chess time limit:10 Sec Memory limit:64 MB
submit:1039 solved:864
[Submit] [Status] [Discuss] Description gives a number of points on the circumference, the length of the arc between the known point and the point, 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. The input first behaves as an integer n, representing the number of points, and the next n rows are the number of distinct rectangles formed by the output of each arc length that is divided by these n points, sample Input8
1
2
2
3
1
1
3
3
Sample Output3
HINT
n<= 20
Source
Conscience data range divided into minutes to water problem ...
#include <iostream>#include<cstdio>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>using namespacestd;intn,ans,s[ -];inlineintRead () {intA=0, f=1;CharC=GetChar (); while(c<'0'|| C>'9') {if(c=='-') f=-1; C=GetChar ();} while(c>='0'&&c<='9') {a=a*Ten+c-'0'; C=GetChar ();} returnA *F;}intMain () {n=read (); for(intI=1; i<=n;i++) { intx=read (); S[i]=s[i-1]+x; } for(intI=1; i<=n;i++) for(intj=i+1; j<=n;j++) for(intk=j+1; k<=n;k++) for(intl=k+1; l<=n;l++) if(S[j]-s[i]==s[l]-s[k]&&s[n]-s[l]+s[i]==s[k]-s[j]) ans++; printf ("%d", ans); return 0;}
[AHOI2009] [BZOJ1800] Fly Flight Chess | enumeration | violence