Hex Artifact Content
Not logged in

Artifact bca49fe15601fcf21dd40874ee0cbccef1c5cb98:


0000: 23 69 6e 63 6c 75 64 65 20 3c 69 6f 73 74 72 65  #include <iostre
0010: 61 6d 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 73  am>..#include <s
0020: 73 74 72 65 61 6d 3e 0d 0a 23 69 6e 63 6c 75 64  stream>..#includ
0030: 65 20 3c 69 6f 6d 61 6e 69 70 3e 0d 0a 23 69 6e  e <iomanip>..#in
0040: 63 6c 75 64 65 20 3c 76 65 63 74 6f 72 3e 0d 0a  clude <vector>..
0050: 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 6e 67  #include <string
0060: 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 6d 61 70  >..#include <map
0070: 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 73 65 74  >..#include <set
0080: 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 61 6c 67  >..#include <alg
0090: 6f 72 69 74 68 6d 3e 0d 0a 23 69 6e 63 6c 75 64  orithm>..#includ
00a0: 65 20 3c 6e 75 6d 65 72 69 63 3e 0d 0a 23 69 6e  e <numeric>..#in
00b0: 63 6c 75 64 65 20 3c 69 74 65 72 61 74 6f 72 3e  clude <iterator>
00c0: 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 66 75 6e 63  ..#include <func
00d0: 74 69 6f 6e 61 6c 3e 0d 0a 23 69 6e 63 6c 75 64  tional>..#includ
00e0: 65 20 3c 63 6f 6d 70 6c 65 78 3e 0d 0a 23 69 6e  e <complex>..#in
00f0: 63 6c 75 64 65 20 3c 71 75 65 75 65 3e 0d 0a 23  clude <queue>..#
0100: 69 6e 63 6c 75 64 65 20 3c 73 74 61 63 6b 3e 0d  include <stack>.
0110: 0a 23 69 6e 63 6c 75 64 65 20 3c 63 6d 61 74 68  .#include <cmath
0120: 3e 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 63 61 73  >..#include <cas
0130: 73 65 72 74 3e 0d 0a 23 69 6e 63 6c 75 64 65 20  sert>..#include 
0140: 3c 74 75 70 6c 65 3e 0d 0a 75 73 69 6e 67 20 6e  <tuple>..using n
0150: 61 6d 65 73 70 61 63 65 20 73 74 64 3b 0d 0a 74  amespace std;..t
0160: 79 70 65 64 65 66 20 6c 6f 6e 67 20 6c 6f 6e 67  ypedef long long
0170: 20 4c 4c 3b 0d 0a 74 79 70 65 64 65 66 20 63 6f   LL;..typedef co
0180: 6d 70 6c 65 78 3c 64 6f 75 62 6c 65 3e 20 43 4d  mplex<double> CM
0190: 50 3b 0d 0a 0d 0a 63 6c 61 73 73 20 53 69 6d 69  P;....class Simi
01a0: 6c 61 72 52 61 74 69 6e 67 47 72 61 70 68 20 7b  larRatingGraph {
01b0: 20 70 75 62 6c 69 63 3a 0d 0a 09 64 6f 75 62 6c   public:...doubl
01c0: 65 20 6d 61 78 4c 65 6e 67 74 68 28 76 65 63 74  e maxLength(vect
01d0: 6f 72 20 3c 69 6e 74 3e 20 64 61 74 65 2c 20 76  or <int> date, v
01e0: 65 63 74 6f 72 20 3c 69 6e 74 3e 20 72 61 74 69  ector <int> rati
01f0: 6e 67 29 0d 0a 09 7b 0d 0a 09 09 63 6f 6e 73 74  ng)...{....const
0200: 20 69 6e 74 20 4e 20 3d 20 64 61 74 65 2e 73 69   int N = date.si
0210: 7a 65 28 29 3b 0d 0a 09 09 64 6f 75 62 6c 65 20  ze();....double 
0220: 62 65 73 74 20 3d 20 30 2e 30 3b 0d 0a 0d 0a 09  best = 0.0;.....
0230: 09 66 6f 72 28 69 6e 74 20 73 3d 30 3b 20 73 2b  .for(int s=0; s+
0240: 31 3c 4e 3b 20 2b 2b 73 29 0d 0a 09 09 66 6f 72  1<N; ++s)....for
0250: 28 69 6e 74 20 74 3d 73 2b 31 3b 20 74 2b 31 3c  (int t=s+1; t+1<
0260: 4e 3b 20 2b 2b 74 29 0d 0a 09 09 7b 0d 0a 09 09  N; ++t)....{....
0270: 09 2f 2f 20 61 20 64 5b 73 5d 20 20 20 2b 20 62  .// a d[s]   + b
0280: 20 3d 20 64 5b 74 5d 0d 0a 09 09 09 2f 2f 20 61   = d[t].....// a
0290: 20 64 5b 73 2b 31 5d 20 2b 20 62 20 3d 20 64 5b   d[s+1] + b = d[
02a0: 74 2b 31 5d 0d 0a 09 09 09 2f 2f 20 61 20 72 5b  t+1].....// a r[
02b0: 73 5d 20 20 20 2b 20 63 20 3d 20 72 5b 74 5d 0d  s]   + c = r[t].
02c0: 0a 09 09 09 2f 2f 20 61 20 72 5b 73 2b 31 5d 20  ....// a r[s+1] 
02d0: 2b 20 63 20 3d 20 72 5b 74 2b 31 5d 0d 0a 0d 0a  + c = r[t+1]....
02e0: 09 09 09 64 6f 75 62 6c 65 20 61 20 3d 20 28 64  ...double a = (d
02f0: 61 74 65 5b 74 2b 31 5d 2d 64 61 74 65 5b 74 5d  ate[t+1]-date[t]
0300: 29 20 2f 20 64 6f 75 62 6c 65 28 64 61 74 65 5b  ) / double(date[
0310: 73 2b 31 5d 20 2d 20 64 61 74 65 5b 73 5d 29 3b  s+1] - date[s]);
0320: 0d 0a 09 09 09 64 6f 75 62 6c 65 20 62 20 3d 20  .....double b = 
0330: 64 61 74 65 5b 74 5d 20 2d 20 61 2a 64 61 74 65  date[t] - a*date
0340: 5b 73 5d 3b 0d 0a 09 09 09 64 6f 75 62 6c 65 20  [s];.....double 
0350: 63 20 3d 20 72 61 74 69 6e 67 5b 74 5d 20 2d 20  c = rating[t] - 
0360: 61 2a 72 61 74 69 6e 67 5b 73 5d 3b 0d 0a 0d 0a  a*rating[s];....
0370: 09 09 09 64 6f 75 62 6c 65 20 6c 31 3d 30 2e 30  ...double l1=0.0
0380: 2c 20 6c 32 3d 30 2e 30 3b 0d 0a 09 09 09 66 6f  , l2=0.0;.....fo
0390: 72 28 69 6e 74 20 6b 3d 31 3b 20 74 2b 6b 3c 4e  r(int k=1; t+k<N
03a0: 3b 20 2b 2b 6b 29 20 7b 0d 0a 09 09 09 09 69 66  ; ++k) {......if
03b0: 28 20 21 65 71 28 61 2a 64 61 74 65 5b 73 2b 6b  ( !eq(a*date[s+k
03c0: 5d 2b 62 2c 20 64 61 74 65 5b 74 2b 6b 5d 29 20  ]+b, date[t+k]) 
03d0: 29 20 62 72 65 61 6b 3b 0d 0a 09 09 09 09 69 66  ) break;......if
03e0: 28 20 21 65 71 28 61 2a 72 61 74 69 6e 67 5b 73  ( !eq(a*rating[s
03f0: 2b 6b 5d 2b 63 2c 20 72 61 74 69 6e 67 5b 74 2b  +k]+c, rating[t+
0400: 6b 5d 29 20 29 20 62 72 65 61 6b 3b 0d 0a 09 09  k]) ) break;....
0410: 09 09 6c 31 20 2b 3d 20 73 71 72 74 28 70 6f 77  ..l1 += sqrt(pow
0420: 28 64 61 74 65 5b 73 2b 6b 5d 2d 64 61 74 65 5b  (date[s+k]-date[
0430: 73 2b 6b 2d 31 5d 2c 32 29 20 2b 20 70 6f 77 28  s+k-1],2) + pow(
0440: 72 61 74 69 6e 67 5b 73 2b 6b 5d 2d 72 61 74 69  rating[s+k]-rati
0450: 6e 67 5b 73 2b 6b 2d 31 5d 2c 32 29 29 3b 0d 0a  ng[s+k-1],2));..
0460: 09 09 09 09 6c 32 20 2b 3d 20 73 71 72 74 28 70  ....l2 += sqrt(p
0470: 6f 77 28 64 61 74 65 5b 74 2b 6b 5d 2d 64 61 74  ow(date[t+k]-dat
0480: 65 5b 74 2b 6b 2d 31 5d 2c 32 29 20 2b 20 70 6f  e[t+k-1],2) + po
0490: 77 28 72 61 74 69 6e 67 5b 74 2b 6b 5d 2d 72 61  w(rating[t+k]-ra
04a0: 74 69 6e 67 5b 74 2b 6b 2d 31 5d 2c 32 29 29 3b  ting[t+k-1],2));
04b0: 0d 0a 09 09 09 7d 0d 0a 09 09 09 62 65 73 74 20  .....}.....best 
04c0: 3d 20 6d 61 78 28 62 65 73 74 2c 20 6d 61 78 28  = max(best, max(
04d0: 6c 31 2c 20 6c 32 29 29 3b 0d 0a 09 09 7d 0d 0a  l1, l2));....}..
04e0: 09 09 72 65 74 75 72 6e 20 62 65 73 74 3b 0d 0a  ..return best;..
04f0: 09 7d 0d 0a 0d 0a 09 64 6f 75 62 6c 65 20 65 71  .}.....double eq
0500: 28 64 6f 75 62 6c 65 20 78 2c 20 69 6e 74 20 76  (double x, int v
0510: 29 20 7b 0d 0a 09 09 72 65 74 75 72 6e 20 69 6e  ) {....return in
0520: 74 28 66 6c 6f 6f 72 28 78 2b 30 2e 35 29 29 20  t(floor(x+0.5)) 
0530: 3d 3d 20 76 3b 0d 0a 09 7d 0d 0a 7d 3b 0d 0a 0d  == v;...}..};...
0540: 0a 2f 2f 20 42 45 47 49 4e 20 43 55 54 20 48 45  .// BEGIN CUT HE
0550: 52 45 0d 0a 23 69 6e 63 6c 75 64 65 20 3c 63 74  RE..#include <ct
0560: 69 6d 65 3e 0d 0a 64 6f 75 62 6c 65 20 73 74 61  ime>..double sta
0570: 72 74 5f 74 69 6d 65 3b 20 73 74 72 69 6e 67 20  rt_time; string 
0580: 74 69 6d 65 72 28 29 0d 0a 20 7b 20 6f 73 74 72  timer().. { ostr
0590: 69 6e 67 73 74 72 65 61 6d 20 6f 73 3b 20 6f 73  ingstream os; os
05a0: 20 3c 3c 20 22 20 28 22 20 3c 3c 20 69 6e 74 28   << " (" << int(
05b0: 28 63 6c 6f 63 6b 28 29 2d 73 74 61 72 74 5f 74  (clock()-start_t
05c0: 69 6d 65 29 2f 43 4c 4f 43 4b 53 5f 50 45 52 5f  ime)/CLOCKS_PER_
05d0: 53 45 43 2a 31 30 30 30 29 20 3c 3c 20 22 20 6d  SEC*1000) << " m
05e0: 73 65 63 29 22 3b 20 72 65 74 75 72 6e 20 6f 73  sec)"; return os
05f0: 2e 73 74 72 28 29 3b 20 7d 0d 0a 74 65 6d 70 6c  .str(); }..templ
0600: 61 74 65 3c 74 79 70 65 6e 61 6d 65 20 54 3e 20  ate<typename T> 
0610: 6f 73 74 72 65 61 6d 26 20 6f 70 65 72 61 74 6f  ostream& operato
0620: 72 3c 3c 28 6f 73 74 72 65 61 6d 26 20 6f 73 2c  r<<(ostream& os,
0630: 20 63 6f 6e 73 74 20 76 65 63 74 6f 72 3c 54 3e   const vector<T>
0640: 26 20 76 29 0d 0a 20 7b 20 6f 73 20 3c 3c 20 22  & v).. { os << "
0650: 7b 20 22 3b 0d 0a 20 20 20 66 6f 72 28 74 79 70  { ";..   for(typ
0660: 65 6e 61 6d 65 20 76 65 63 74 6f 72 3c 54 3e 3a  ename vector<T>:
0670: 3a 63 6f 6e 73 74 5f 69 74 65 72 61 74 6f 72 20  :const_iterator 
0680: 69 74 3d 76 2e 62 65 67 69 6e 28 29 3b 20 69 74  it=v.begin(); it
0690: 21 3d 76 2e 65 6e 64 28 29 3b 20 2b 2b 69 74 29  !=v.end(); ++it)
06a0: 0d 0a 20 20 20 6f 73 20 3c 3c 20 27 5c 22 27 20  ..   os << '\"' 
06b0: 3c 3c 20 2a 69 74 20 3c 3c 20 27 5c 22 27 20 3c  << *it << '\"' <
06c0: 3c 20 28 69 74 2b 31 3d 3d 76 2e 65 6e 64 28 29  < (it+1==v.end()
06d0: 20 3f 20 22 22 20 3a 20 22 2c 20 22 29 3b 20 6f   ? "" : ", "); o
06e0: 73 20 3c 3c 20 22 20 7d 22 3b 20 72 65 74 75 72  s << " }"; retur
06f0: 6e 20 6f 73 3b 20 7d 0d 0a 76 6f 69 64 20 76 65  n os; }..void ve
0700: 72 69 66 79 5f 63 61 73 65 28 63 6f 6e 73 74 20  rify_case(const 
0710: 64 6f 75 62 6c 65 26 20 45 78 70 65 63 74 65 64  double& Expected
0720: 2c 20 63 6f 6e 73 74 20 64 6f 75 62 6c 65 26 20  , const double& 
0730: 52 65 63 65 69 76 65 64 29 20 7b 0d 0a 20 62 6f  Received) {.. bo
0740: 6f 6c 20 6f 6b 20 3d 20 28 61 62 73 28 45 78 70  ol ok = (abs(Exp
0750: 65 63 74 65 64 20 2d 20 52 65 63 65 69 76 65 64  ected - Received
0760: 29 20 3c 20 31 65 2d 39 29 3b 0d 0a 20 69 66 28  ) < 1e-9);.. if(
0770: 6f 6b 29 20 63 65 72 72 20 3c 3c 20 22 50 41 53  ok) cerr << "PAS
0780: 53 45 44 22 20 3c 3c 20 74 69 6d 65 72 28 29 20  SED" << timer() 
0790: 3c 3c 20 65 6e 64 6c 3b 20 20 65 6c 73 65 20 7b  << endl;  else {
07a0: 20 63 65 72 72 20 3c 3c 20 22 46 41 49 4c 45 44   cerr << "FAILED
07b0: 22 20 3c 3c 20 74 69 6d 65 72 28 29 20 3c 3c 20  " << timer() << 
07c0: 65 6e 64 6c 3b 0d 0a 20 63 65 72 72 20 3c 3c 20  endl;.. cerr << 
07d0: 22 5c 74 6f 3a 20 5c 22 22 20 3c 3c 20 45 78 70  "\to: \"" << Exp
07e0: 65 63 74 65 64 20 3c 3c 20 27 5c 22 27 20 3c 3c  ected << '\"' <<
07f0: 20 65 6e 64 6c 20 3c 3c 20 22 5c 74 78 3a 20 5c   endl << "\tx: \
0800: 22 22 20 3c 3c 20 52 65 63 65 69 76 65 64 20 3c  "" << Received <
0810: 3c 20 27 5c 22 27 20 3c 3c 20 65 6e 64 6c 3b 20  < '\"' << endl; 
0820: 7d 20 7d 0d 0a 23 64 65 66 69 6e 65 20 43 41 53  } }..#define CAS
0830: 45 28 4e 29 20 7b 63 65 72 72 20 3c 3c 20 22 54  E(N) {cerr << "T
0840: 65 73 74 20 43 61 73 65 20 23 22 20 3c 3c 20 4e  est Case #" << N
0850: 20 3c 3c 20 22 2e 2e 2e 22 20 3c 3c 20 66 6c 75   << "..." << flu
0860: 73 68 3b 20 73 74 61 72 74 5f 74 69 6d 65 3d 63  sh; start_time=c
0870: 6c 6f 63 6b 28 29 3b 0d 0a 23 64 65 66 69 6e 65  lock();..#define
0880: 20 45 4e 44 09 20 76 65 72 69 66 79 5f 63 61 73   END. verify_cas
0890: 65 28 5f 2c 20 53 69 6d 69 6c 61 72 52 61 74 69  e(_, SimilarRati
08a0: 6e 67 47 72 61 70 68 28 29 2e 6d 61 78 4c 65 6e  ngGraph().maxLen
08b0: 67 74 68 28 64 61 74 65 2c 20 72 61 74 69 6e 67  gth(date, rating
08c0: 29 29 3b 7d 0d 0a 69 6e 74 20 6d 61 69 6e 28 29  ));}..int main()
08d0: 7b 0d 0a 0d 0a 43 41 53 45 28 30 29 0d 0a 09 69  {....CASE(0)...i
08e0: 6e 74 20 64 61 74 65 5f 5b 5d 20 3d 20 7b 31 2c  nt date_[] = {1,
08f0: 32 2c 34 2c 38 2c 31 36 2c 33 32 7d 3b 0d 0a 09  2,4,8,16,32};...
0900: 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 64    vector <int> d
0910: 61 74 65 28 64 61 74 65 5f 2c 20 64 61 74 65 5f  ate(date_, date_
0920: 2b 73 69 7a 65 6f 66 28 64 61 74 65 5f 29 2f 73  +sizeof(date_)/s
0930: 69 7a 65 6f 66 28 2a 64 61 74 65 5f 29 29 3b 20  izeof(*date_)); 
0940: 0d 0a 09 69 6e 74 20 72 61 74 69 6e 67 5f 5b 5d  ...int rating_[]
0950: 20 3d 20 7b 31 2c 32 2c 34 2c 38 2c 31 36 2c 33   = {1,2,4,8,16,3
0960: 32 7d 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c  2};...  vector <
0970: 69 6e 74 3e 20 72 61 74 69 6e 67 28 72 61 74 69  int> rating(rati
0980: 6e 67 5f 2c 20 72 61 74 69 6e 67 5f 2b 73 69 7a  ng_, rating_+siz
0990: 65 6f 66 28 72 61 74 69 6e 67 5f 29 2f 73 69 7a  eof(rating_)/siz
09a0: 65 6f 66 28 2a 72 61 74 69 6e 67 5f 29 29 3b 20  eof(*rating_)); 
09b0: 0d 0a 09 64 6f 75 62 6c 65 20 5f 20 3d 20 34 32  ...double _ = 42
09c0: 2e 34 32 36 34 30 36 38 37 31 31 39 32 38 35 3b  .42640687119285;
09d0: 20 0d 0a 45 4e 44 0d 0a 43 41 53 45 28 31 29 0d   ..END..CASE(1).
09e0: 0a 09 69 6e 74 20 64 61 74 65 5f 5b 5d 20 3d 20  ..int date_[] = 
09f0: 7b 38 31 2c 31 30 34 2c 31 32 30 2c 31 32 34 2c  {81,104,120,124,
0a00: 31 33 34 2c 31 33 37 7d 3b 0d 0a 09 20 20 76 65  134,137};...  ve
0a10: 63 74 6f 72 20 3c 69 6e 74 3e 20 64 61 74 65 28  ctor <int> date(
0a20: 64 61 74 65 5f 2c 20 64 61 74 65 5f 2b 73 69 7a  date_, date_+siz
0a30: 65 6f 66 28 64 61 74 65 5f 29 2f 73 69 7a 65 6f  eof(date_)/sizeo
0a40: 66 28 2a 64 61 74 65 5f 29 29 3b 20 0d 0a 09 69  f(*date_)); ...i
0a50: 6e 74 20 72 61 74 69 6e 67 5f 5b 5d 20 3d 20 7b  nt rating_[] = {
0a60: 31 38 36 36 2c 32 33 33 32 2c 32 35 31 30 2c 32  1866,2332,2510,2
0a70: 36 37 38 2c 32 38 37 36 2c 33 30 30 32 7d 3b 0d  678,2876,3002};.
0a80: 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e  ..  vector <int>
0a90: 20 72 61 74 69 6e 67 28 72 61 74 69 6e 67 5f 2c   rating(rating_,
0aa0: 20 72 61 74 69 6e 67 5f 2b 73 69 7a 65 6f 66 28   rating_+sizeof(
0ab0: 72 61 74 69 6e 67 5f 29 2f 73 69 7a 65 6f 66 28  rating_)/sizeof(
0ac0: 2a 72 61 74 69 6e 67 5f 29 29 3b 20 0d 0a 09 64  *rating_)); ...d
0ad0: 6f 75 62 6c 65 20 5f 20 3d 20 31 36 38 2e 30 34  ouble _ = 168.04
0ae0: 37 36 31 32 33 30 30 38 30 30 30 34 3b 20 0d 0a  761230080004; ..
0af0: 45 4e 44 0d 0a 43 41 53 45 28 32 29 0d 0a 09 69  END..CASE(2)...i
0b00: 6e 74 20 64 61 74 65 5f 5b 5d 20 3d 20 7b 31 30  nt date_[] = {10
0b10: 2c 31 31 2c 31 33 2c 31 35 2c 31 39 7d 3b 0d 0a  ,11,13,15,19};..
0b20: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
0b30: 64 61 74 65 28 64 61 74 65 5f 2c 20 64 61 74 65  date(date_, date
0b40: 5f 2b 73 69 7a 65 6f 66 28 64 61 74 65 5f 29 2f  _+sizeof(date_)/
0b50: 73 69 7a 65 6f 66 28 2a 64 61 74 65 5f 29 29 3b  sizeof(*date_));
0b60: 20 0d 0a 09 69 6e 74 20 72 61 74 69 6e 67 5f 5b   ...int rating_[
0b70: 5d 20 3d 20 7b 31 30 2c 31 34 2c 31 35 2c 32 33  ] = {10,14,15,23
0b80: 2c 32 35 7d 3b 0d 0a 09 20 20 76 65 63 74 6f 72  ,25};...  vector
0b90: 20 3c 69 6e 74 3e 20 72 61 74 69 6e 67 28 72 61   <int> rating(ra
0ba0: 74 69 6e 67 5f 2c 20 72 61 74 69 6e 67 5f 2b 73  ting_, rating_+s
0bb0: 69 7a 65 6f 66 28 72 61 74 69 6e 67 5f 29 2f 73  izeof(rating_)/s
0bc0: 69 7a 65 6f 66 28 2a 72 61 74 69 6e 67 5f 29 29  izeof(*rating_))
0bd0: 3b 20 0d 0a 09 64 6f 75 62 6c 65 20 5f 20 3d 20  ; ...double _ = 
0be0: 31 32 2e 37 31 38 33 34 37 32 30 36 32 33 34 39  12.7183472062349
0bf0: 3b 20 0d 0a 45 4e 44 0d 0a 43 41 53 45 28 33 29  ; ..END..CASE(3)
0c00: 0d 0a 09 69 6e 74 20 64 61 74 65 5f 5b 5d 20 3d  ...int date_[] =
0c10: 20 7b 31 2c 32 2c 33 2c 34 7d 3b 0d 0a 09 20 20   {1,2,3,4};...  
0c20: 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 64 61 74  vector <int> dat
0c30: 65 28 64 61 74 65 5f 2c 20 64 61 74 65 5f 2b 73  e(date_, date_+s
0c40: 69 7a 65 6f 66 28 64 61 74 65 5f 29 2f 73 69 7a  izeof(date_)/siz
0c50: 65 6f 66 28 2a 64 61 74 65 5f 29 29 3b 20 0d 0a  eof(*date_)); ..
0c60: 09 69 6e 74 20 72 61 74 69 6e 67 5f 5b 5d 20 3d  .int rating_[] =
0c70: 20 7b 31 37 30 30 2c 31 38 30 30 2c 31 37 35 30   {1700,1800,1750
0c80: 2c 31 38 35 30 7d 3b 0d 0a 09 20 20 76 65 63 74  ,1850};...  vect
0c90: 6f 72 20 3c 69 6e 74 3e 20 72 61 74 69 6e 67 28  or <int> rating(
0ca0: 72 61 74 69 6e 67 5f 2c 20 72 61 74 69 6e 67 5f  rating_, rating_
0cb0: 2b 73 69 7a 65 6f 66 28 72 61 74 69 6e 67 5f 29  +sizeof(rating_)
0cc0: 2f 73 69 7a 65 6f 66 28 2a 72 61 74 69 6e 67 5f  /sizeof(*rating_
0cd0: 29 29 3b 20 0d 0a 09 64 6f 75 62 6c 65 20 5f 20  )); ...double _ 
0ce0: 3d 20 31 30 30 2e 30 30 34 39 39 39 38 37 35 30  = 100.0049998750
0cf0: 30 36 32 35 3b 20 0d 0a 45 4e 44 0d 0a 43 41 53  0625; ..END..CAS
0d00: 45 28 34 29 0d 0a 09 69 6e 74 20 64 61 74 65 5f  E(4)...int date_
0d10: 5b 5d 20 3d 20 7b 31 2c 32 2c 33 2c 34 7d 3b 0d  [] = {1,2,3,4};.
0d20: 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e  ..  vector <int>
0d30: 20 64 61 74 65 28 64 61 74 65 5f 2c 20 64 61 74   date(date_, dat
0d40: 65 5f 2b 73 69 7a 65 6f 66 28 64 61 74 65 5f 29  e_+sizeof(date_)
0d50: 2f 73 69 7a 65 6f 66 28 2a 64 61 74 65 5f 29 29  /sizeof(*date_))
0d60: 3b 20 0d 0a 09 69 6e 74 20 72 61 74 69 6e 67 5f  ; ...int rating_
0d70: 5b 5d 20 3d 20 7b 31 2c 34 2c 39 2c 31 36 7d 3b  [] = {1,4,9,16};
0d80: 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74  ...  vector <int
0d90: 3e 20 72 61 74 69 6e 67 28 72 61 74 69 6e 67 5f  > rating(rating_
0da0: 2c 20 72 61 74 69 6e 67 5f 2b 73 69 7a 65 6f 66  , rating_+sizeof
0db0: 28 72 61 74 69 6e 67 5f 29 2f 73 69 7a 65 6f 66  (rating_)/sizeof
0dc0: 28 2a 72 61 74 69 6e 67 5f 29 29 3b 20 0d 0a 09  (*rating_)); ...
0dd0: 64 6f 75 62 6c 65 20 5f 20 3d 20 30 2e 30 3b 20  double _ = 0.0; 
0de0: 0d 0a 45 4e 44 0d 0a 43 41 53 45 28 35 29 0d 0a  ..END..CASE(5)..
0df0: 09 69 6e 74 20 64 61 74 65 5f 5b 5d 20 3d 20 7b  .int date_[] = {
0e00: 35 2c 31 31 2c 32 35 2c 35 38 2c 39 32 2c 31 36  5,11,25,58,92,16
0e10: 32 2c 32 35 35 2c 33 35 30 2c 34 35 38 2c 35 36  2,255,350,458,56
0e20: 36 2c 36 37 37 2c 37 39 32 2c 39 31 39 2c 31 30  6,677,792,919,10
0e30: 35 31 2c 31 31 38 39 2c 31 33 33 31 2c 31 34 38  51,1189,1331,148
0e40: 39 2c 31 36 37 33 2c 31 38 38 32 2c 32 30 39 33  9,1673,1882,2093
0e50: 2c 32 33 31 35 2c 32 35 34 31 2c 32 37 37 31 2c  ,2315,2541,2771,
0e60: 33 30 31 32 2c 33 32 35 34 2c 33 35 32 34 2c 33  3012,3254,3524,3
0e70: 37 39 37 2c 34 30 38 37 2c 34 33 37 39 2c 34 36  797,4087,4379,46
0e80: 37 35 2c 34 39 37 33 2c 35 32 37 38 2c 35 35 38  75,4973,5278,558
0e90: 38 2c 35 39 30 34 2c 36 32 32 35 2c 36 35 35 30  8,5904,6225,6550
0ea0: 2c 36 38 38 38 2c 37 32 34 39 2c 37 36 31 32 2c  ,6888,7249,7612,
0eb0: 38 30 31 38 2c 38 34 32 38 2c 38 38 34 37 2c 39  8018,8428,8847,9
0ec0: 32 36 37 2c 39 36 38 38 2c 31 30 31 30 39 2c 31  267,9688,10109,1
0ed0: 30 35 33 30 2c 31 30 39 36 34 2c 31 31 34 30 37  0530,10964,11407
0ee0: 2c 31 31 38 37 30 2c 31 32 33 34 30 2c 31 32 38  ,11870,12340,128
0ef0: 31 31 2c 31 33 32 38 38 2c 31 33 37 36 38 2c 31  11,13288,13768,1
0f00: 34 32 34 39 2c 31 34 37 33 34 2c 31 35 32 34 32  4249,14734,15242
0f10: 2c 31 35 37 37 34 2c 31 36 33 30 36 2c 31 36 38  ,15774,16306,168
0f20: 34 37 2c 31 37 34 30 30 2c 31 37 39 36 36 2c 31  47,17400,17966,1
0f30: 38 35 33 33 2c 31 39 31 30 38 2c 31 39 36 39 32  8533,19108,19692
0f40: 2c 32 30 32 37 38 2c 32 30 38 37 31 2c 32 31 34  ,20278,20871,214
0f50: 37 31 2c 32 32 30 37 34 2c 32 32 36 37 39 2c 32  71,22074,22679,2
0f60: 33 32 39 37 2c 32 33 39 31 36 2c 32 34 35 35 33  3297,23916,24553
0f70: 2c 32 35 31 39 30 2c 32 35 38 32 39 2c 32 36 34  ,25190,25829,264
0f80: 37 32 2c 32 37 31 33 35 2c 32 37 38 31 34 2c 32  72,27135,27814,2
0f90: 38 34 39 37 2c 32 39 31 38 31 2c 32 39 38 36 35  8497,29181,29865
0fa0: 2c 33 30 35 35 35 2c 33 31 32 37 32 2c 33 31 39  ,30555,31272,319
0fb0: 39 34 2c 33 32 37 32 39 2c 33 33 34 38 37 2c 33  94,32729,33487,3
0fc0: 34 32 34 36 2c 33 35 30 30 35 2c 33 35 37 36 34  4246,35005,35764
0fd0: 2c 33 36 35 33 37 2c 33 37 33 32 36 2c 33 38 31  ,36537,37326,381
0fe0: 31 39 2c 33 38 39 31 33 2c 33 39 37 32 35 2c 34  19,38913,39725,4
0ff0: 30 35 33 38 2c 34 31 33 36 30 2c 34 32 31 38 35  0538,41360,42185
1000: 2c 34 33 30 31 30 2c 34 33 38 34 30 2c 34 34 36  ,43010,43840,446
1010: 37 31 2c 34 35 35 30 39 2c 34 36 33 35 30 2c 34  71,45509,46350,4
1020: 37 32 30 35 2c 34 38 30 36 33 2c 34 38 39 33 32  7205,48063,48932
1030: 2c 34 39 38 30 37 2c 35 30 36 39 31 2c 35 31 35  ,49807,50691,515
1040: 37 37 2c 35 32 34 36 34 2c 35 33 32 38 39 2c 35  77,52464,53289,5
1050: 34 31 31 39 2c 35 34 39 35 30 2c 35 35 37 38 38  4119,54950,55788
1060: 2c 35 36 36 32 39 2c 35 37 34 38 34 2c 35 38 33  ,56629,57484,583
1070: 34 32 2c 35 39 32 31 31 2c 36 30 30 38 36 2c 36  42,59211,60086,6
1080: 30 39 37 30 2c 36 31 38 35 36 2c 36 32 37 34 33  0970,61856,62743
1090: 2c 36 33 35 36 38 2c 36 34 33 39 38 2c 36 35 33  ,63568,64398,653
10a0: 38 38 7d 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20  88};...  vector 
10b0: 3c 69 6e 74 3e 20 64 61 74 65 28 64 61 74 65 5f  <int> date(date_
10c0: 2c 20 64 61 74 65 5f 2b 73 69 7a 65 6f 66 28 64  , date_+sizeof(d
10d0: 61 74 65 5f 29 2f 73 69 7a 65 6f 66 28 2a 64 61  ate_)/sizeof(*da
10e0: 74 65 5f 29 29 3b 20 0d 0a 09 69 6e 74 20 72 61  te_)); ...int ra
10f0: 74 69 6e 67 5f 5b 5d 20 3d 20 7b 31 35 30 35 2c  ting_[] = {1505,
1100: 31 34 36 32 2c 31 34 33 36 2c 31 34 31 36 2c 31  1462,1436,1416,1
1110: 34 36 33 2c 31 34 32 31 2c 31 34 31 31 2c 31 34  463,1421,1411,14
1120: 35 30 2c 31 34 39 37 2c 31 34 36 35 2c 31 34 32  50,1497,1465,142
1130: 33 2c 31 33 39 34 2c 31 33 39 31 2c 31 33 36 37  3,1394,1391,1367
1140: 2c 31 33 35 38 2c 31 33 32 33 2c 31 33 31 30 2c  ,1358,1323,1310,
1150: 31 32 37 39 2c 31 32 36 38 2c 31 32 37 39 2c 31  1279,1268,1279,1
1160: 33 31 31 2c 31 33 34 32 2c 31 33 35 39 2c 31 33  311,1342,1359,13
1170: 38 37 2c 31 34 31 34 2c 31 33 37 36 2c 31 34 32  87,1414,1376,142
1180: 34 2c 31 33 38 32 2c 31 33 37 33 2c 31 33 33 35  4,1382,1373,1335
1190: 2c 31 33 35 39 2c 31 33 31 38 2c 31 32 37 35 2c  ,1359,1318,1275,
11a0: 31 32 36 36 2c 31 32 32 37 2c 31 32 30 33 2c 31  1266,1227,1203,1
11b0: 31 36 38 2c 31 31 36 33 2c 31 31 38 34 2c 31 31  168,1163,1184,11
11c0: 34 34 2c 31 31 36 39 2c 31 32 30 37 2c 31 32 35  44,1169,1207,125
11d0: 30 2c 31 32 33 35 2c 31 32 30 39 2c 31 31 36 32  0,1235,1209,1162
11e0: 2c 31 31 32 34 2c 31 31 34 38 2c 31 31 36 38 2c  ,1124,1148,1168,
11f0: 31 32 30 32 2c 31 31 39 30 2c 31 31 35 35 2c 31  1202,1190,1155,1
1200: 31 37 39 2c 31 31 39 34 2c 31 31 39 35 2c 31 31  179,1194,1195,11
1210: 39 35 2c 31 32 30 33 2c 31 32 34 30 2c 31 32 31  95,1203,1240,121
1220: 38 2c 31 32 34 35 2c 31 32 32 30 2c 31 31 39 30  8,1245,1220,1190
1230: 2c 31 32 30 38 2c 31 31 38 30 2c 31 31 38 32 2c  ,1208,1180,1182,
1240: 31 31 34 38 2c 31 31 33 39 2c 31 31 32 36 2c 31  1148,1139,1126,1
1250: 31 35 32 2c 31 31 35 39 2c 31 31 34 37 2c 31 31  152,1159,1147,11
1260: 35 38 2c 31 31 31 32 2c 31 30 39 31 2c 31 31 30  58,1112,1091,110
1270: 31 2c 31 31 31 36 2c 31 31 32 33 2c 31 30 38 36  1,1116,1123,1086
1280: 2c 31 31 32 36 2c 31 31 31 30 2c 31 31 32 38 2c  ,1126,1110,1128,
1290: 31 30 38 35 2c 31 31 33 32 2c 31 31 34 35 2c 31  1085,1132,1145,1
12a0: 31 33 35 2c 31 31 34 30 2c 31 31 31 37 2c 31 30  135,1140,1117,10
12b0: 38 31 2c 31 31 32 30 2c 31 31 33 31 2c 31 30 38  81,1120,1131,108
12c0: 31 2c 31 30 33 32 2c 31 30 37 31 2c 31 31 30 32  1,1032,1071,1102
12d0: 2c 31 30 37 31 2c 31 30 36 35 2c 31 30 36 38 2c  ,1071,1065,1068,
12e0: 31 30 32 37 2c 39 38 30 2c 39 34 37 2c 39 38 37  1027,980,947,987
12f0: 2c 39 36 38 2c 39 35 39 2c 39 38 30 2c 39 39 30  ,968,959,980,990
1300: 2c 39 37 34 2c 31 30 30 33 2c 39 39 36 2c 39 39  ,974,1003,996,99
1310: 39 2c 39 35 38 2c 39 31 31 2c 38 37 38 2c 39 31  9,958,911,878,91
1320: 38 2c 38 39 39 2c 38 39 30 2c 39 31 31 2c 39 32  8,899,890,911,92
1330: 31 2c 39 30 35 2c 39 33 34 2c 39 32 37 2c 39 33  1,905,934,927,93
1340: 30 2c 38 38 39 2c 38 34 34 7d 3b 0d 0a 09 20 20  0,889,844};...  
1350: 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 72 61 74  vector <int> rat
1360: 69 6e 67 28 72 61 74 69 6e 67 5f 2c 20 72 61 74  ing(rating_, rat
1370: 69 6e 67 5f 2b 73 69 7a 65 6f 66 28 72 61 74 69  ing_+sizeof(rati
1380: 6e 67 5f 29 2f 73 69 7a 65 6f 66 28 2a 72 61 74  ng_)/sizeof(*rat
1390: 69 6e 67 5f 29 29 3b 20 0d 0a 09 64 6f 75 62 6c  ing_)); ...doubl
13a0: 65 20 5f 20 3d 20 31 31 39 34 30 2e 31 37 39 32  e _ = 11940.1792
13b0: 37 31 30 31 34 35 33 36 3b 20 0d 0a 45 4e 44 0d  71014536; ..END.
13c0: 0a 2f 2a 0d 0a 43 41 53 45 28 36 29 0d 0a 09 69  ./*..CASE(6)...i
13d0: 6e 74 20 64 61 74 65 5f 5b 5d 20 3d 20 3b 0d 0a  nt date_[] = ;..
13e0: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
13f0: 64 61 74 65 28 64 61 74 65 5f 2c 20 64 61 74 65  date(date_, date
1400: 5f 2b 73 69 7a 65 6f 66 28 64 61 74 65 5f 29 2f  _+sizeof(date_)/
1410: 73 69 7a 65 6f 66 28 2a 64 61 74 65 5f 29 29 3b  sizeof(*date_));
1420: 20 0d 0a 09 69 6e 74 20 72 61 74 69 6e 67 5f 5b   ...int rating_[
1430: 5d 20 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72  ] = ;...  vector
1440: 20 3c 69 6e 74 3e 20 72 61 74 69 6e 67 28 72 61   <int> rating(ra
1450: 74 69 6e 67 5f 2c 20 72 61 74 69 6e 67 5f 2b 73  ting_, rating_+s
1460: 69 7a 65 6f 66 28 72 61 74 69 6e 67 5f 29 2f 73  izeof(rating_)/s
1470: 69 7a 65 6f 66 28 2a 72 61 74 69 6e 67 5f 29 29  izeof(*rating_))
1480: 3b 20 0d 0a 09 64 6f 75 62 6c 65 20 5f 20 3d 20  ; ...double _ = 
1490: 3b 20 0d 0a 45 4e 44 0d 0a 43 41 53 45 28 37 29  ; ..END..CASE(7)
14a0: 0d 0a 09 69 6e 74 20 64 61 74 65 5f 5b 5d 20 3d  ...int date_[] =
14b0: 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c 69   ;...  vector <i
14c0: 6e 74 3e 20 64 61 74 65 28 64 61 74 65 5f 2c 20  nt> date(date_, 
14d0: 64 61 74 65 5f 2b 73 69 7a 65 6f 66 28 64 61 74  date_+sizeof(dat
14e0: 65 5f 29 2f 73 69 7a 65 6f 66 28 2a 64 61 74 65  e_)/sizeof(*date
14f0: 5f 29 29 3b 20 0d 0a 09 69 6e 74 20 72 61 74 69  _)); ...int rati
1500: 6e 67 5f 5b 5d 20 3d 20 3b 0d 0a 09 20 20 76 65  ng_[] = ;...  ve
1510: 63 74 6f 72 20 3c 69 6e 74 3e 20 72 61 74 69 6e  ctor <int> ratin
1520: 67 28 72 61 74 69 6e 67 5f 2c 20 72 61 74 69 6e  g(rating_, ratin
1530: 67 5f 2b 73 69 7a 65 6f 66 28 72 61 74 69 6e 67  g_+sizeof(rating
1540: 5f 29 2f 73 69 7a 65 6f 66 28 2a 72 61 74 69 6e  _)/sizeof(*ratin
1550: 67 5f 29 29 3b 20 0d 0a 09 64 6f 75 62 6c 65 20  g_)); ...double 
1560: 5f 20 3d 20 3b 20 0d 0a 45 4e 44 0d 0a 2a 2f 0d  _ = ; ..END..*/.
1570: 0a 7d 0d 0a 2f 2f 20 45 4e 44 20 43 55 54 20 48  .}..// END CUT H
1580: 45 52 45 0d 0a                                   ERE..