Hdu4624 Endless Spin (min max inclusive+dp)

Min max exclusion:

$$max\{a_i\}=\sum\limits_{S}(-1)^{|s|-1}min\{a_i|a_i \in S\}$$

As for the proof, a number $a $can be regarded as a set $ {1... a } $, so max is equivalent to taking union set, min is equivalent to taking intersection set, and it becomes a general exclusion

Then this question can dp

However, I have been stuck with the following code, which is probably correct(

 one #include<bits/stdc++.h> two #include<tr1/unordered_map> three  #define CLR(a,x) memset(a,x,sizeof(a)) four  #define MP make_pair five  #define fi first six  #define se second seven  using  namespace std; eight typedef long  long ll; nine typedef unsigned long  long ull; ten typedef long  double ld; eleven typedef pair< int , int > pa; twelve  const  int maxn= fifty-five ; thirteen 
 fourteen  inline ll rd(){ fifteen ll x= zero ; char c=getchar(); int neg= one ; sixteen      while (c< ' zero ' ||c> ' nine ' ){ if (c== ' - ' ) neg=- one ; c= getchar();} seventeen      while (c>= ' zero ' &&c<= ' nine ' ) x=x* ten +c- ' zero ' ,c= getchar(); eighteen      return x* neg; nineteen  } twenty 
 twenty-one  int N,f[maxn][ two ][ two *maxn* maxn]; twenty-two 
 twenty-three  int main(){ twenty-four      // freopen("","r",stdin);
 twenty-five      for ( int T=rd(); T; T-- ){ twenty-six N= rd(); twenty-seven ld ans= zero ; twenty-eight CLR(f, zero ); f[ zero ][ zero ][ zero ]= one ; twenty-nine          for ( int i= one ; i<=N+ one ; i++ ){ thirty              for ( int b= zero ; b<= one ; b++ ){ thirty-one                  for ( int ii= zero ; ii<i; ii++ ){ thirty-two                      for ( int j= zero ; j<=ii*(ii+ one ); j++ ){ thirty-three f[i][b][j+(i-ii- one )*(i-ii)]+=f[ii][! b][j]; thirty-four  } thirty-five  } thirty-six  } thirty-seven  } thirty-eight          for ( int b= zero ; b<= one ; b++ ){ thirty-nine              for ( int j= zero ; j<N*(N+ one ); j++ ){ forty ans+=(b?- one : one )*( one . 0L /( one - one . 0L *j/(N*(N+ one ))))*f[N+ one ][b][j]; forty-one  } forty-two  } forty-three printf( " %.15Lf\n " ,ans); forty-four  } forty-five      return  zero ; forty-six }

 

posted @ 2019-06-07 16:23   Ressed   Reading( two hundred and thirty-one Comments( zero edit   Collection   report