1. Guan Yu
(Guanyu.cpp/c/pas)
"Problem description"
XPP studies the philosophy of astronomy every day, and there are some thoughts that we cannot understand in life.
After a dull academic day, XPP opened the http://web.sanguosha.com, ready to use his beloved Guan Yu to abuse
People. Entered the eight-person status bureau, as a master, xpp decisively elected Guan Yu, with Guan Yu pick 7 people.
Why does xpp like Guan Yu, the warlord? Because the Holy Grail is a great skill.
Holy Grail--you can use or play any one of your hearts or cards when you kill them.
This skill can be easily killed if used well. So xpp 7 of them all relaxed.
Kill.
Although XPP will always be annihilation, he thinks of the question: Who should kill first and then kill
Who is it?
Play the three countries killed people are sitting in a circle, everyone to the card heap distance equal, that is, there is a person all
The circle on the border. As my lord, Xpp wanted to kill 4 anti-thieves. According to his reasoning, this should be the case.
: The position of the 4 anti-thieves must constitute a rectangle. Now, Xpp want to know how many kinds of anti-thieves this board might have
The combination.
XPP IQ is too strong to think of such low-end problems, and then you will have to do this problem.
Input
The input file name is guanyu.in.
The first line contains an integer n, representing the number of games except XPP (excluding Xpp, who is the Lord).
The second line consists of n integers representing the length of the interval between players.
Output
The output file name is Guanyu.out.
Outputs a total of T-lines, each containing a real number, representing the desired expected value.
"Input and Output sample"
Guanyu.in Guanyu.out
8
1 2 2 3 1 1 3 3
3
"Data Range"
For 30% of data, n≤20.
For 100% of data, 4≤n≤2000.
——————————————
I am a Wei powder to do shu problem really uncomfortable ... This is a strange n^2logn, is to enumerate an edge, calculate its adjacent edge, and then calculate it to the edge, but the array is small and then GG, and later changed to a large
The answer is actually a circle ... Enumerates whether two points are diameters and then arithmetic progression calculates one, N^2 's
"An array of small destruction of life"
"The right thing to do"
1#include <iostream>2#include <string.h>3#include <cstdlib>4#include <cstdio>5#include <algorithm>6#include <cstring>7#include <vector>8#include <ctime>9 #defineIvorysiTen #defineMo 10007 One #defineSiji (i,x,y) for (int i= (x); i<= (y); i++) A #defineGongzi (j,x,y) for (int j= (x); j>= (y); j--) - #defineXiaosiji (i,x,y) for (int i= (x);i< (y); i++) - #defineSigongzi (j,x,y) for (int j= (x);j> (y); j--) the #defineIvory (i,x) for (int i=head[x];i;i=edge[i].next) - #definePII pair<int,int> - #defineFi first - #defineSe Second + #defineINF 10000000 - using namespacestd; +typedefLong Longll; A inta[4005],sum[4005],n,ans,po; at BOOLBinaryintIlintirintval) { - intq=il-1; - while(il<ir) { - intMid= (il+ir+1) >>1; - if(Sum[mid]-sum[q]<=val) il=mid; - Elseir=mid-1; in } - if(Sum[il]-sum[q]==val) {Po=il;return true;} to Else return false; + } - intMain () { the #ifdef Ivorysi *Freopen ("guanyu.in","R", stdin); $Freopen ("Guanyu.out","W", stdout);Panax Notoginseng #else -Freopen ("f1.in","R", stdin); the #endif +scanf"%d",&n); ASiji (I,1, N) { thescanf"%d",&a[i]); +sum[i]=sum[i-1]+A[i]; - } $Siji (I,1, N) { $a[n+i]=A[i]; -sum[n+i]=sum[n+i-1]+a[n+i]; - } theSiji (I,1, N) { -Xiaosiji (J,0, N) {Wuyi inttmp=sum[j+i]-sum[i-1]; the if(tmp*2>=sum[n])Continue; - intTmp2= (sum[n]-tmp*2)/2; Wu if(!binary (i+j+1, i+n-1, TMP2))Continue; - if(!binary (po+1, i+n-1, TMP))Continue; About++ans; $ - } - } -printf"%d\n", ans/4); A}
The old driver's strange Noip analog T1-guanyu