Hex Artifact Content
Not logged in

Artifact 526b59207f22295c3ccfdd45faffe4c904c3cc32:


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 4c 4c 20 67 63 64 28 4c 4c 20  P;....LL gcd(LL 
01a0: 61 2c 20 4c 4c 20 62 29 0d 0a 7b 0d 0a 09 77 68  a, LL b)..{...wh
01b0: 69 6c 65 28 61 29 0d 0a 09 09 73 77 61 70 28 61  ile(a)....swap(a
01c0: 2c 20 62 25 3d 61 29 3b 0d 0a 09 72 65 74 75 72  , b%=a);...retur
01d0: 6e 20 62 3b 0d 0a 7d 0d 0a 0d 0a 63 6c 61 73 73  n b;..}....class
01e0: 20 45 6c 65 63 74 72 6f 6e 69 63 50 65 74 20 7b   ElectronicPet {
01f0: 20 70 75 62 6c 69 63 3a 0d 0a 09 76 65 63 74 6f   public:...vecto
0200: 72 3c 6c 6f 6e 67 20 6c 6f 6e 67 3e 20 6d 69 6e  r<long long> min
0210: 69 6d 75 6d 53 65 63 28 76 65 63 74 6f 72 20 3c  imumSec(vector <
0220: 69 6e 74 3e 20 70 65 72 69 6f 64 31 2c 20 76 65  int> period1, ve
0230: 63 74 6f 72 20 3c 69 6e 74 3e 20 74 69 6d 65 31  ctor <int> time1
0240: 2c 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 70  , vector <int> p
0250: 65 72 69 6f 64 32 2c 20 76 65 63 74 6f 72 20 3c  eriod2, vector <
0260: 69 6e 74 3e 20 74 69 6d 65 32 29 0d 0a 09 7b 0d  int> time2)...{.
0270: 0a 09 09 76 65 63 74 6f 72 3c 4c 4c 3e 20 51 3b  ...vector<LL> Q;
0280: 0d 0a 09 09 66 6f 72 28 69 6e 74 20 69 3d 30 3b  ....for(int i=0;
0290: 20 69 3c 70 65 72 69 6f 64 31 2e 73 69 7a 65 28   i<period1.size(
02a0: 29 3b 20 2b 2b 69 29 0d 0a 09 09 09 51 2e 70 75  ); ++i).....Q.pu
02b0: 73 68 5f 62 61 63 6b 28 73 6f 6c 76 65 28 70 65  sh_back(solve(pe
02c0: 72 69 6f 64 31 5b 69 5d 2c 20 70 65 72 69 6f 64  riod1[i], period
02d0: 32 5b 69 5d 2c 20 74 69 6d 65 31 5b 69 5d 2c 20  2[i], time1[i], 
02e0: 74 69 6d 65 32 5b 69 5d 29 29 3b 0d 0a 09 09 72  time2[i]));....r
02f0: 65 74 75 72 6e 20 51 3b 0d 0a 09 7d 0d 0a 0d 0a  eturn Q;...}....
0300: 09 4c 4c 20 73 6f 6c 76 65 28 4c 4c 20 50 31 2c  .LL solve(LL P1,
0310: 20 4c 4c 20 50 32 2c 20 4c 4c 20 54 31 2c 20 4c   LL P2, LL T1, L
0320: 4c 20 54 32 29 0d 0a 09 7b 0d 0a 09 09 4c 4c 20  L T2)...{....LL 
0330: 61 31 20 3d 20 50 31 2a 28 54 31 2d 31 29 3b 0d  a1 = P1*(T1-1);.
0340: 0a 09 09 4c 4c 20 62 31 20 3d 20 50 32 2a 28 54  ...LL b1 = P2*(T
0350: 32 2d 31 29 3b 0d 0a 0d 0a 09 09 69 66 28 67 63  2-1);......if(gc
0360: 64 28 50 31 2c 20 50 32 29 20 21 3d 20 31 29 0d  d(P1, P2) != 1).
0370: 0a 09 09 09 72 65 74 75 72 6e 20 61 31 3d 3d 62  ....return a1==b
0380: 31 20 3f 20 61 31 2b 31 20 3a 20 6d 61 78 28 61  1 ? a1+1 : max(a
0390: 31 2c 62 31 29 3b 0d 0a 0d 0a 09 09 2f 2f 20 28  1,b1);......// (
03a0: 50 31 2c 20 54 31 29 20 69 73 20 64 6f 6d 69 6e  P1, T1) is domin
03b0: 61 6e 74 2e 0d 0a 09 09 69 66 28 61 31 3c 62 31  ant.....if(a1<b1
03c0: 20 7c 7c 20 28 61 31 3d 3d 62 31 20 26 26 20 50   || (a1==b1 && P
03d0: 31 3c 50 32 29 29 20 7b 0d 0a 09 09 09 73 77 61  1<P2)) {.....swa
03e0: 70 28 50 31 2c 20 50 32 29 3b 0d 0a 09 09 09 73  p(P1, P2);.....s
03f0: 77 61 70 28 54 31 2c 20 54 32 29 3b 0d 0a 09 09  wap(T1, T2);....
0400: 7d 0d 0a 0d 0a 09 09 2f 2f 20 2d 31 20 3d 3d 20  }......// -1 == 
0410: 50 32 2a 6b 20 6d 6f 64 20 50 31 3f 0d 0a 09 09  P2*k mod P1?....
0420: 2f 2f 20 54 4f 44 4f 3a 20 78 67 63 64 0d 0a 09  // TODO: xgcd...
0430: 09 4c 4c 20 6b 3d 31 3b 0d 0a 09 09 77 68 69 6c  .LL k=1;....whil
0440: 65 28 50 32 2a 6b 25 50 31 20 21 3d 20 50 31 2d  e(P2*k%P1 != P1-
0450: 31 29 0d 0a 09 09 09 2b 2b 6b 3b 0d 0a 09 09 2f  1).....++k;..../
0460: 2f 20 44 75 72 69 6e 67 20 28 50 32 2a 6b 2b 31  / During (P2*k+1
0470: 29 2f 50 31 2b 31 20 70 31 2c 20 49 20 63 61 6e  )/P1+1 p1, I can
0480: 20 75 73 65 20 6b 20 70 32 2e 0d 0a 09 09 4c 4c   use k p2.....LL
0490: 20 76 20 3d 20 28 50 32 2a 6b 2b 31 29 2f 50 31   v = (P2*k+1)/P1
04a0: 2b 31 3b 0d 0a 09 09 4c 4c 20 63 6f 6e 73 75 6d  +1;....LL consum
04b0: 65 20 3d 20 54 31 2f 76 2a 6b 3b 0d 0a 09 09 72  e = T1/v*k;....r
04c0: 65 74 75 72 6e 20 6d 61 78 28 50 31 2a 28 54 31  eturn max(P1*(T1
04d0: 2d 31 29 2c 20 50 31 2a 28 6d 61 78 28 31 4c 4c  -1), P1*(max(1LL
04e0: 2c 54 31 2f 76 2a 76 29 2d 31 29 2b 31 2b 50 32  ,T1/v*v)-1)+1+P2
04f0: 2a 28 6d 61 78 28 31 4c 4c 2c 54 32 2d 63 6f 6e  *(max(1LL,T2-con
0500: 73 75 6d 65 29 2d 31 29 29 3b 0d 0a 09 7d 0d 0a  sume)-1));...}..
0510: 7d 3b 0d 0a 0d 0a 2f 2f 20 42 45 47 49 4e 20 43  };....// BEGIN C
0520: 55 54 20 48 45 52 45 0d 0a 23 69 6e 63 6c 75 64  UT HERE..#includ
0530: 65 20 3c 63 74 69 6d 65 3e 0d 0a 64 6f 75 62 6c  e <ctime>..doubl
0540: 65 20 73 74 61 72 74 5f 74 69 6d 65 3b 20 73 74  e start_time; st
0550: 72 69 6e 67 20 74 69 6d 65 72 28 29 0d 0a 20 7b  ring timer().. {
0560: 20 6f 73 74 72 69 6e 67 73 74 72 65 61 6d 20 6f   ostringstream o
0570: 73 3b 20 6f 73 20 3c 3c 20 22 20 28 22 20 3c 3c  s; os << " (" <<
0580: 20 69 6e 74 28 28 63 6c 6f 63 6b 28 29 2d 73 74   int((clock()-st
0590: 61 72 74 5f 74 69 6d 65 29 2f 43 4c 4f 43 4b 53  art_time)/CLOCKS
05a0: 5f 50 45 52 5f 53 45 43 2a 31 30 30 30 29 20 3c  _PER_SEC*1000) <
05b0: 3c 20 22 20 6d 73 65 63 29 22 3b 20 72 65 74 75  < " msec)"; retu
05c0: 72 6e 20 6f 73 2e 73 74 72 28 29 3b 20 7d 0d 0a  rn os.str(); }..
05d0: 74 65 6d 70 6c 61 74 65 3c 74 79 70 65 6e 61 6d  template<typenam
05e0: 65 20 54 3e 20 6f 73 74 72 65 61 6d 26 20 6f 70  e T> ostream& op
05f0: 65 72 61 74 6f 72 3c 3c 28 6f 73 74 72 65 61 6d  erator<<(ostream
0600: 26 20 6f 73 2c 20 63 6f 6e 73 74 20 76 65 63 74  & os, const vect
0610: 6f 72 3c 54 3e 26 20 76 29 0d 0a 20 7b 20 6f 73  or<T>& v).. { os
0620: 20 3c 3c 20 22 7b 20 22 3b 0d 0a 20 20 20 66 6f   << "{ ";..   fo
0630: 72 28 74 79 70 65 6e 61 6d 65 20 76 65 63 74 6f  r(typename vecto
0640: 72 3c 54 3e 3a 3a 63 6f 6e 73 74 5f 69 74 65 72  r<T>::const_iter
0650: 61 74 6f 72 20 69 74 3d 76 2e 62 65 67 69 6e 28  ator it=v.begin(
0660: 29 3b 20 69 74 21 3d 76 2e 65 6e 64 28 29 3b 20  ); it!=v.end(); 
0670: 2b 2b 69 74 29 0d 0a 20 20 20 6f 73 20 3c 3c 20  ++it)..   os << 
0680: 27 5c 22 27 20 3c 3c 20 2a 69 74 20 3c 3c 20 27  '\"' << *it << '
0690: 5c 22 27 20 3c 3c 20 28 69 74 2b 31 3d 3d 76 2e  \"' << (it+1==v.
06a0: 65 6e 64 28 29 20 3f 20 22 22 20 3a 20 22 2c 20  end() ? "" : ", 
06b0: 22 29 3b 20 6f 73 20 3c 3c 20 22 20 7d 22 3b 20  "); os << " }"; 
06c0: 72 65 74 75 72 6e 20 6f 73 3b 20 7d 0d 0a 76 6f  return os; }..vo
06d0: 69 64 20 76 65 72 69 66 79 5f 63 61 73 65 28 63  id verify_case(c
06e0: 6f 6e 73 74 20 76 65 63 74 6f 72 3c 6c 6f 6e 67  onst vector<long
06f0: 20 6c 6f 6e 67 3e 26 20 45 78 70 65 63 74 65 64   long>& Expected
0700: 2c 20 63 6f 6e 73 74 20 76 65 63 74 6f 72 3c 6c  , const vector<l
0710: 6f 6e 67 20 6c 6f 6e 67 3e 26 20 52 65 63 65 69  ong long>& Recei
0720: 76 65 64 29 20 7b 0d 0a 20 62 6f 6f 6c 20 6f 6b  ved) {.. bool ok
0730: 20 3d 20 28 45 78 70 65 63 74 65 64 20 3d 3d 20   = (Expected == 
0740: 52 65 63 65 69 76 65 64 29 3b 0d 0a 20 69 66 28  Received);.. if(
0750: 6f 6b 29 20 63 65 72 72 20 3c 3c 20 22 50 41 53  ok) cerr << "PAS
0760: 53 45 44 22 20 3c 3c 20 74 69 6d 65 72 28 29 20  SED" << timer() 
0770: 3c 3c 20 65 6e 64 6c 3b 20 20 65 6c 73 65 20 7b  << endl;  else {
0780: 20 63 65 72 72 20 3c 3c 20 22 46 41 49 4c 45 44   cerr << "FAILED
0790: 22 20 3c 3c 20 74 69 6d 65 72 28 29 20 3c 3c 20  " << timer() << 
07a0: 65 6e 64 6c 3b 0d 0a 20 63 65 72 72 20 3c 3c 20  endl;.. cerr << 
07b0: 22 5c 74 6f 3a 20 22 20 3c 3c 20 45 78 70 65 63  "\to: " << Expec
07c0: 74 65 64 20 3c 3c 20 65 6e 64 6c 20 3c 3c 20 22  ted << endl << "
07d0: 5c 74 78 3a 20 22 20 3c 3c 20 52 65 63 65 69 76  \tx: " << Receiv
07e0: 65 64 20 3c 3c 20 65 6e 64 6c 3b 20 7d 20 7d 0d  ed << endl; } }.
07f0: 0a 23 64 65 66 69 6e 65 20 43 41 53 45 28 4e 29  .#define CASE(N)
0800: 20 7b 63 65 72 72 20 3c 3c 20 22 54 65 73 74 20   {cerr << "Test 
0810: 43 61 73 65 20 23 22 20 3c 3c 20 4e 20 3c 3c 20  Case #" << N << 
0820: 22 2e 2e 2e 22 20 3c 3c 20 66 6c 75 73 68 3b 20  "..." << flush; 
0830: 73 74 61 72 74 5f 74 69 6d 65 3d 63 6c 6f 63 6b  start_time=clock
0840: 28 29 3b 0d 0a 23 64 65 66 69 6e 65 20 45 4e 44  ();..#define END
0850: 09 20 76 65 72 69 66 79 5f 63 61 73 65 28 5f 2c  . verify_case(_,
0860: 20 45 6c 65 63 74 72 6f 6e 69 63 50 65 74 28 29   ElectronicPet()
0870: 2e 6d 69 6e 69 6d 75 6d 53 65 63 28 70 65 72 69  .minimumSec(peri
0880: 6f 64 31 2c 20 74 69 6d 65 31 2c 20 70 65 72 69  od1, time1, peri
0890: 6f 64 32 2c 20 74 69 6d 65 32 29 29 3b 7d 0d 0a  od2, time2));}..
08a0: 69 6e 74 20 6d 61 69 6e 28 29 7b 0d 0a 0d 0a 43  int main(){....C
08b0: 41 53 45 28 30 29 0d 0a 09 69 6e 74 20 70 65 72  ASE(0)...int per
08c0: 69 6f 64 31 5f 5b 5d 20 3d 20 7b 32 7d 3b 0d 0a  iod1_[] = {2};..
08d0: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
08e0: 70 65 72 69 6f 64 31 28 70 65 72 69 6f 64 31 5f  period1(period1_
08f0: 2c 20 70 65 72 69 6f 64 31 5f 2b 73 69 7a 65 6f  , period1_+sizeo
0900: 66 28 70 65 72 69 6f 64 31 5f 29 2f 73 69 7a 65  f(period1_)/size
0910: 6f 66 28 2a 70 65 72 69 6f 64 31 5f 29 29 3b 20  of(*period1_)); 
0920: 0d 0a 09 69 6e 74 20 74 69 6d 65 31 5f 5b 5d 20  ...int time1_[] 
0930: 3d 20 7b 32 7d 3b 0d 0a 09 20 20 76 65 63 74 6f  = {2};...  vecto
0940: 72 20 3c 69 6e 74 3e 20 74 69 6d 65 31 28 74 69  r <int> time1(ti
0950: 6d 65 31 5f 2c 20 74 69 6d 65 31 5f 2b 73 69 7a  me1_, time1_+siz
0960: 65 6f 66 28 74 69 6d 65 31 5f 29 2f 73 69 7a 65  eof(time1_)/size
0970: 6f 66 28 2a 74 69 6d 65 31 5f 29 29 3b 20 0d 0a  of(*time1_)); ..
0980: 09 69 6e 74 20 70 65 72 69 6f 64 32 5f 5b 5d 20  .int period2_[] 
0990: 3d 20 7b 32 7d 3b 0d 0a 09 20 20 76 65 63 74 6f  = {2};...  vecto
09a0: 72 20 3c 69 6e 74 3e 20 70 65 72 69 6f 64 32 28  r <int> period2(
09b0: 70 65 72 69 6f 64 32 5f 2c 20 70 65 72 69 6f 64  period2_, period
09c0: 32 5f 2b 73 69 7a 65 6f 66 28 70 65 72 69 6f 64  2_+sizeof(period
09d0: 32 5f 29 2f 73 69 7a 65 6f 66 28 2a 70 65 72 69  2_)/sizeof(*peri
09e0: 6f 64 32 5f 29 29 3b 20 0d 0a 09 69 6e 74 20 74  od2_)); ...int t
09f0: 69 6d 65 32 5f 5b 5d 20 3d 20 7b 33 7d 3b 0d 0a  ime2_[] = {3};..
0a00: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
0a10: 74 69 6d 65 32 28 74 69 6d 65 32 5f 2c 20 74 69  time2(time2_, ti
0a20: 6d 65 32 5f 2b 73 69 7a 65 6f 66 28 74 69 6d 65  me2_+sizeof(time
0a30: 32 5f 29 2f 73 69 7a 65 6f 66 28 2a 74 69 6d 65  2_)/sizeof(*time
0a40: 32 5f 29 29 3b 20 0d 0a 09 6c 6f 6e 67 20 6c 6f  2_)); ...long lo
0a50: 6e 67 20 5f 5f 5b 5d 20 3d 20 7b 34 20 7d 3b 0d  ng __[] = {4 };.
0a60: 0a 09 20 20 76 65 63 74 6f 72 3c 6c 6f 6e 67 20  ..  vector<long 
0a70: 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20 5f 5f 2b 73  long> _(__, __+s
0a80: 69 7a 65 6f 66 28 5f 5f 29 2f 73 69 7a 65 6f 66  izeof(__)/sizeof
0a90: 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e 44 0d 0a 43  (*__)); ..END..C
0aa0: 41 53 45 28 31 29 0d 0a 09 69 6e 74 20 70 65 72  ASE(1)...int per
0ab0: 69 6f 64 31 5f 5b 5d 20 3d 20 7b 31 7d 3b 0d 0a  iod1_[] = {1};..
0ac0: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
0ad0: 70 65 72 69 6f 64 31 28 70 65 72 69 6f 64 31 5f  period1(period1_
0ae0: 2c 20 70 65 72 69 6f 64 31 5f 2b 73 69 7a 65 6f  , period1_+sizeo
0af0: 66 28 70 65 72 69 6f 64 31 5f 29 2f 73 69 7a 65  f(period1_)/size
0b00: 6f 66 28 2a 70 65 72 69 6f 64 31 5f 29 29 3b 20  of(*period1_)); 
0b10: 0d 0a 09 69 6e 74 20 74 69 6d 65 31 5f 5b 5d 20  ...int time1_[] 
0b20: 3d 20 7b 31 30 7d 3b 0d 0a 09 20 20 76 65 63 74  = {10};...  vect
0b30: 6f 72 20 3c 69 6e 74 3e 20 74 69 6d 65 31 28 74  or <int> time1(t
0b40: 69 6d 65 31 5f 2c 20 74 69 6d 65 31 5f 2b 73 69  ime1_, time1_+si
0b50: 7a 65 6f 66 28 74 69 6d 65 31 5f 29 2f 73 69 7a  zeof(time1_)/siz
0b60: 65 6f 66 28 2a 74 69 6d 65 31 5f 29 29 3b 20 0d  eof(*time1_)); .
0b70: 0a 09 69 6e 74 20 70 65 72 69 6f 64 32 5f 5b 5d  ..int period2_[]
0b80: 20 3d 20 7b 32 7d 3b 0d 0a 09 20 20 76 65 63 74   = {2};...  vect
0b90: 6f 72 20 3c 69 6e 74 3e 20 70 65 72 69 6f 64 32  or <int> period2
0ba0: 28 70 65 72 69 6f 64 32 5f 2c 20 70 65 72 69 6f  (period2_, perio
0bb0: 64 32 5f 2b 73 69 7a 65 6f 66 28 70 65 72 69 6f  d2_+sizeof(perio
0bc0: 64 32 5f 29 2f 73 69 7a 65 6f 66 28 2a 70 65 72  d2_)/sizeof(*per
0bd0: 69 6f 64 32 5f 29 29 3b 20 0d 0a 09 69 6e 74 20  iod2_)); ...int 
0be0: 74 69 6d 65 32 5f 5b 5d 20 3d 20 7b 34 7d 3b 0d  time2_[] = {4};.
0bf0: 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e  ..  vector <int>
0c00: 20 74 69 6d 65 32 28 74 69 6d 65 32 5f 2c 20 74   time2(time2_, t
0c10: 69 6d 65 32 5f 2b 73 69 7a 65 6f 66 28 74 69 6d  ime2_+sizeof(tim
0c20: 65 32 5f 29 2f 73 69 7a 65 6f 66 28 2a 74 69 6d  e2_)/sizeof(*tim
0c30: 65 32 5f 29 29 3b 20 0d 0a 09 6c 6f 6e 67 20 6c  e2_)); ...long l
0c40: 6f 6e 67 20 5f 5f 5b 5d 20 3d 20 7b 31 33 20 7d  ong __[] = {13 }
0c50: 3b 0d 0a 09 20 20 76 65 63 74 6f 72 3c 6c 6f 6e  ;...  vector<lon
0c60: 67 20 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20 5f 5f  g long> _(__, __
0c70: 2b 73 69 7a 65 6f 66 28 5f 5f 29 2f 73 69 7a 65  +sizeof(__)/size
0c80: 6f 66 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e 44 0d  of(*__)); ..END.
0c90: 0a 43 41 53 45 28 32 29 0d 0a 09 69 6e 74 20 70  .CASE(2)...int p
0ca0: 65 72 69 6f 64 31 5f 5b 5d 20 3d 20 7b 37 33 35  eriod1_[] = {735
0cb0: 37 2c 31 30 2c 32 7d 3b 0d 0a 09 20 20 76 65 63  7,10,2};...  vec
0cc0: 74 6f 72 20 3c 69 6e 74 3e 20 70 65 72 69 6f 64  tor <int> period
0cd0: 31 28 70 65 72 69 6f 64 31 5f 2c 20 70 65 72 69  1(period1_, peri
0ce0: 6f 64 31 5f 2b 73 69 7a 65 6f 66 28 70 65 72 69  od1_+sizeof(peri
0cf0: 6f 64 31 5f 29 2f 73 69 7a 65 6f 66 28 2a 70 65  od1_)/sizeof(*pe
0d00: 72 69 6f 64 31 5f 29 29 3b 20 0d 0a 09 69 6e 74  riod1_)); ...int
0d10: 20 74 69 6d 65 31 5f 5b 5d 20 3d 20 7b 37 33 35   time1_[] = {735
0d20: 36 2c 35 30 2c 31 30 30 30 30 30 30 7d 3b 0d 0a  6,50,1000000};..
0d30: 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20  .  vector <int> 
0d40: 74 69 6d 65 31 28 74 69 6d 65 31 5f 2c 20 74 69  time1(time1_, ti
0d50: 6d 65 31 5f 2b 73 69 7a 65 6f 66 28 74 69 6d 65  me1_+sizeof(time
0d60: 31 5f 29 2f 73 69 7a 65 6f 66 28 2a 74 69 6d 65  1_)/sizeof(*time
0d70: 31 5f 29 29 3b 20 0d 0a 09 69 6e 74 20 70 65 72  1_)); ...int per
0d80: 69 6f 64 32 5f 5b 5d 20 3d 20 7b 37 33 35 36 2c  iod2_[] = {7356,
0d90: 33 2c 33 7d 3b 0d 0a 09 20 20 76 65 63 74 6f 72  3,3};...  vector
0da0: 20 3c 69 6e 74 3e 20 70 65 72 69 6f 64 32 28 70   <int> period2(p
0db0: 65 72 69 6f 64 32 5f 2c 20 70 65 72 69 6f 64 32  eriod2_, period2
0dc0: 5f 2b 73 69 7a 65 6f 66 28 70 65 72 69 6f 64 32  _+sizeof(period2
0dd0: 5f 29 2f 73 69 7a 65 6f 66 28 2a 70 65 72 69 6f  _)/sizeof(*perio
0de0: 64 32 5f 29 29 3b 20 0d 0a 09 69 6e 74 20 74 69  d2_)); ...int ti
0df0: 6d 65 32 5f 5b 5d 20 3d 20 7b 37 33 35 37 2c 31  me2_[] = {7357,1
0e00: 36 37 2c 39 30 30 30 30 30 7d 3b 0d 0a 09 20 20  67,900000};...  
0e10: 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 74 69 6d  vector <int> tim
0e20: 65 32 28 74 69 6d 65 32 5f 2c 20 74 69 6d 65 32  e2(time2_, time2
0e30: 5f 2b 73 69 7a 65 6f 66 28 74 69 6d 65 32 5f 29  _+sizeof(time2_)
0e40: 2f 73 69 7a 65 6f 66 28 2a 74 69 6d 65 32 5f 29  /sizeof(*time2_)
0e50: 29 3b 20 0d 0a 09 6c 6f 6e 67 20 6c 6f 6e 67 20  ); ...long long 
0e60: 5f 5f 5b 5d 20 3d 20 7b 35 34 31 31 30 37 33 37  __[] = {54110737
0e70: 2c 20 35 31 30 2c 20 32 37 39 39 39 39 38 20 7d  , 510, 2799998 }
0e80: 3b 0d 0a 09 20 20 76 65 63 74 6f 72 3c 6c 6f 6e  ;...  vector<lon
0e90: 67 20 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20 5f 5f  g long> _(__, __
0ea0: 2b 73 69 7a 65 6f 66 28 5f 5f 29 2f 73 69 7a 65  +sizeof(__)/size
0eb0: 6f 66 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e 44 0d  of(*__)); ..END.
0ec0: 0a 43 41 53 45 28 33 29 0d 0a 09 69 6e 74 20 70  .CASE(3)...int p
0ed0: 65 72 69 6f 64 31 5f 5b 5d 20 3d 20 7b 34 30 37  eriod1_[] = {407
0ee0: 36 38 32 38 30 30 2c 34 38 34 38 37 37 30 35 39  682800,484877059
0ef0: 2c 38 33 30 36 37 34 31 37 37 2c 32 32 37 32 38  ,830674177,22728
0f00: 31 30 37 33 2c 31 39 32 38 35 35 32 33 2c 35 36  1073,19285523,56
0f10: 30 39 33 37 37 36 37 2c 39 31 39 32 39 37 36 31  0937767,91929761
0f20: 31 2c 32 33 35 33 31 37 38 38 2c 0d 0a 33 31 36  1,23531788,..316
0f30: 31 35 39 33 34 30 2c 36 37 34 38 30 36 35 31 39  159340,674806519
0f40: 2c 33 32 39 34 33 33 36 36 35 2c 37 33 38 35 33  ,329433665,73853
0f50: 38 34 38 31 2c 36 34 31 32 33 35 38 39 33 2c 37  8481,641235893,7
0f60: 36 35 31 38 31 32 31 33 2c 31 37 34 37 38 35 32  65181213,1747852
0f70: 30 32 2c 33 33 36 31 35 32 32 38 34 2c 0d 0a 35  02,336152284,..5
0f80: 37 30 39 32 31 36 38 33 2c 34 30 30 38 36 37 32  70921683,4008672
0f90: 35 31 2c 37 37 34 32 38 35 34 30 32 2c 39 34 33  51,774285402,943
0fa0: 33 39 30 37 37 31 2c 38 33 37 32 39 35 38 33 31  390771,837295831
0fb0: 2c 32 39 34 35 30 37 30 35 36 2c 34 39 33 37 39  ,294507056,49379
0fc0: 30 38 39 33 2c 35 32 32 32 32 37 32 30 33 2c 0d  0893,522227203,.
0fd0: 0a 34 39 37 39 32 34 36 38 37 2c 35 39 38 38 33  .497924687,59883
0fe0: 34 37 30 35 2c 34 37 35 38 33 31 30 37 35 2c 34  4705,475831075,4
0ff0: 37 35 31 31 34 31 34 31 2c 39 30 35 38 31 33 32  75114141,9058132
1000: 30 39 2c 31 37 30 38 33 32 37 35 32 2c 36 34 31  09,170832752,641
1010: 34 38 34 36 30 33 2c 32 38 39 38 31 33 32 35 39  484603,289813259
1020: 2c 0d 0a 38 36 32 35 34 35 36 39 34 2c 31 37 38  ,..862545694,178
1030: 39 34 34 37 38 31 2c 37 35 35 39 33 31 36 36 31  944781,755931661
1040: 2c 36 32 30 33 33 38 35 35 36 2c 39 37 30 38 36  ,620338556,97086
1050: 37 31 38 35 2c 38 33 39 34 31 34 32 37 2c 31 33  7185,83941427,13
1060: 35 36 37 34 38 31 34 2c 38 39 35 33 36 35 36 34  5674814,89536564
1070: 33 2c 0d 0a 34 37 33 34 34 30 39 31 38 2c 37 31  3,..473440918,71
1080: 38 32 38 32 39 34 39 2c 34 39 39 30 33 31 34 35  8282949,49903145
1090: 32 2c 32 34 35 34 30 36 37 37 31 2c 34 37 32 36  2,245406771,4726
10a0: 34 33 36 33 39 2c 38 35 37 34 31 34 36 30 33 2c  43639,857414603,
10b0: 39 36 39 30 36 33 37 37 33 2c 37 38 34 36 35 39  969063773,784659
10c0: 32 36 2c 0d 0a 31 2c 37 2c 32 2c 38 2c 37 2c 37  26,..1,7,2,8,7,7
10d0: 2c 33 2c 38 2c 31 2c 32 2c 38 2c 36 2c 31 2c 37  ,3,8,1,2,8,6,1,7
10e0: 2c 31 30 2c 35 2c 33 2c 31 30 2c 31 2c 35 2c 35  ,10,5,3,10,1,5,5
10f0: 2c 37 2c 31 2c 31 2c 31 30 2c 39 2c 33 2c 38 2c  ,7,1,1,10,9,3,8,
1100: 35 2c 36 2c 37 2c 33 2c 37 2c 37 2c 35 2c 33 2c  5,6,7,3,7,7,5,3,
1110: 31 2c 34 2c 0d 0a 39 2c 38 2c 31 2c 35 2c 39 2c  1,4,..9,8,1,5,9,
1120: 37 2c 34 2c 37 2c 39 2c 31 7d 3b 0d 0a 09 20 20  7,4,7,9,1};...  
1130: 76 65 63 74 6f 72 20 3c 69 6e 74 3e 20 70 65 72  vector <int> per
1140: 69 6f 64 31 28 70 65 72 69 6f 64 31 5f 2c 20 70  iod1(period1_, p
1150: 65 72 69 6f 64 31 5f 2b 73 69 7a 65 6f 66 28 70  eriod1_+sizeof(p
1160: 65 72 69 6f 64 31 5f 29 2f 73 69 7a 65 6f 66 28  eriod1_)/sizeof(
1170: 2a 70 65 72 69 6f 64 31 5f 29 29 3b 20 0d 0a 09  *period1_)); ...
1180: 69 6e 74 20 74 69 6d 65 31 5f 5b 5d 20 3d 20 7b  int time1_[] = {
1190: 36 38 35 33 32 31 38 38 37 2c 35 36 31 38 34 37  685321887,561847
11a0: 37 36 32 2c 33 36 34 38 36 38 32 31 30 2c 38 36  762,364868210,86
11b0: 37 32 38 35 33 30 31 2c 39 31 34 39 34 35 36 30  7285301,91494560
11c0: 31 2c 31 31 38 37 38 37 38 30 35 2c 35 34 38 33  1,118787805,5483
11d0: 33 32 36 30 37 2c 33 31 33 35 35 33 35 39 2c 0d  32607,31355359,.
11e0: 0a 38 30 33 36 35 30 32 36 31 2c 39 36 30 33 30  .803650261,96030
11f0: 31 35 32 34 2c 32 36 36 34 37 37 36 34 31 2c 33  1524,266477641,3
1200: 39 31 31 30 36 37 33 2c 34 37 34 37 31 38 31 36  9110673,47471816
1210: 39 2c 37 31 33 34 30 34 38 39 2c 36 38 37 31 33  9,71340489,68713
1220: 34 37 38 39 2c 34 39 33 34 30 31 39 36 38 2c 0d  4789,493401968,.
1230: 0a 36 35 33 30 35 38 37 34 33 2c 35 35 37 34 38  .653058743,55748
1240: 36 32 35 2c 35 30 39 30 37 37 34 34 35 2c 32 36  625,509077445,26
1250: 39 39 33 37 39 37 33 2c 37 34 32 38 39 30 37 39  9937973,74289079
1260: 36 2c 35 32 35 38 35 34 39 35 2c 37 32 36 33 35  6,52585495,72635
1270: 37 31 32 35 2c 36 38 34 37 37 34 39 30 2c 0d 0a  7125,68477490,..
1280: 34 2c 37 2c 39 2c 39 2c 37 2c 36 2c 31 2c 37 2c  4,7,9,9,7,6,1,7,
1290: 33 2c 38 2c 36 2c 39 2c 31 2c 39 2c 39 2c 36 2c  3,8,6,9,1,9,9,6,
12a0: 31 30 2c 36 2c 38 2c 38 2c 31 30 2c 39 2c 36 2c  10,6,8,8,10,9,6,
12b0: 35 2c 37 38 31 32 35 30 31 34 37 2c 31 37 30 38  5,781250147,1708
12c0: 37 38 37 37 34 2c 38 35 35 31 33 35 32 32 36 2c  78774,855135226,
12d0: 0d 0a 35 34 39 30 35 39 31 34 33 2c 36 35 34 38  ..549059143,6548
12e0: 37 37 33 34 39 2c 38 30 31 34 32 37 31 36 36 2c  77349,801427166,
12f0: 36 37 33 38 33 30 39 30 36 2c 33 38 36 36 32 39  673830906,386629
1300: 34 34 30 2c 38 35 31 33 39 35 35 31 37 2c 39 30  440,851395517,90
1310: 30 37 39 31 32 33 33 2c 34 34 39 37 32 38 33 38  0791233,44972838
1320: 33 2c 0d 0a 32 35 30 33 39 37 30 33 37 2c 36 39  3,..250397037,69
1330: 31 30 39 36 36 38 2c 35 31 32 38 37 38 34 36 32  109668,512878462
1340: 2c 32 37 32 33 37 39 32 36 2c 32 38 35 38 33 37  ,27237926,285837
1350: 38 38 39 2c 36 36 36 38 38 35 33 37 2c 39 31 30  889,66688537,910
1360: 35 34 39 30 32 2c 37 31 37 37 38 33 36 35 30 2c  54902,717783650,
1370: 33 38 38 32 37 38 36 39 33 2c 0d 0a 32 32 38 39  388278693,..2289
1380: 31 34 32 34 39 2c 39 38 39 31 38 38 38 38 35 2c  14249,989188885,
1390: 35 30 32 37 30 39 32 36 34 2c 36 36 33 38 31 37  502709264,663817
13a0: 37 34 34 2c 36 2c 35 2c 37 2c 36 2c 38 2c 37 2c  744,6,5,7,6,8,7,
13b0: 38 2c 39 2c 38 2c 34 2c 34 2c 38 2c 38 2c 38 2c  8,9,8,4,4,8,8,8,
13c0: 36 2c 38 2c 35 2c 33 2c 36 2c 32 2c 37 2c 32 2c  6,8,5,3,6,2,7,2,
13d0: 36 2c 31 7d 3b 0d 0a 09 20 20 76 65 63 74 6f 72  6,1};...  vector
13e0: 20 3c 69 6e 74 3e 20 74 69 6d 65 31 28 74 69 6d   <int> time1(tim
13f0: 65 31 5f 2c 20 74 69 6d 65 31 5f 2b 73 69 7a 65  e1_, time1_+size
1400: 6f 66 28 74 69 6d 65 31 5f 29 2f 73 69 7a 65 6f  of(time1_)/sizeo
1410: 66 28 2a 74 69 6d 65 31 5f 29 29 3b 20 0d 0a 09  f(*time1_)); ...
1420: 69 6e 74 20 70 65 72 69 6f 64 32 5f 5b 5d 20 3d  int period2_[] =
1430: 20 7b 39 38 36 37 30 35 37 36 33 2c 39 32 37 35   {986705763,9275
1440: 37 34 34 34 35 2c 38 39 32 39 34 38 32 35 34 2c  74445,892948254,
1450: 37 30 34 30 36 36 34 31 35 2c 35 33 35 34 33 36  704066415,535436
1460: 31 36 32 2c 35 39 30 33 30 38 32 35 32 2c 31 37  162,590308252,17
1470: 38 38 39 31 32 32 30 2c 37 34 33 39 32 32 33 32  8891220,74392232
1480: 35 2c 0d 0a 38 35 36 35 36 36 30 32 31 2c 35 31  5,..856566021,51
1490: 38 35 31 39 36 39 30 2c 32 32 35 34 34 30 31 33  8519690,22544013
14a0: 36 2c 37 38 35 39 31 39 39 32 34 2c 35 2c 35 2c  6,785919924,5,5,
14b0: 35 2c 39 2c 39 2c 34 2c 37 2c 31 30 2c 37 2c 39  5,9,9,4,7,10,7,9
14c0: 2c 34 2c 34 2c 38 31 38 39 35 36 36 32 37 2c 34  ,4,4,818956627,4
14d0: 31 37 31 33 35 33 37 39 2c 0d 0a 32 34 38 38 39  17135379,..24889
14e0: 32 30 34 36 2c 31 34 36 30 30 39 31 34 39 2c 37  2046,146009149,7
14f0: 33 39 32 37 37 37 38 35 2c 31 30 39 34 32 33 31  39277785,1094231
1500: 39 35 2c 34 34 30 31 39 38 31 34 31 2c 36 30 35  95,440198141,605
1510: 35 32 35 36 35 35 2c 37 32 38 34 37 38 37 30 33  525655,728478703
1520: 2c 36 32 36 31 37 32 30 36 39 2c 0d 0a 36 33 30  ,626172069,..630
1530: 33 37 30 34 36 38 2c 31 33 30 30 37 36 33 34 39  370468,130076349
1540: 2c 34 2c 31 2c 35 2c 34 2c 39 2c 31 30 2c 33 2c  ,4,1,5,4,9,10,3,
1550: 31 2c 34 2c 39 2c 33 2c 31 2c 35 38 33 30 38 39  1,4,9,3,1,583089
1560: 31 39 31 2c 33 38 38 38 37 30 30 39 39 2c 34 35  191,388870099,45
1570: 33 38 32 37 38 31 39 2c 31 31 31 35 31 36 36 30  3827819,11151660
1580: 33 2c 0d 0a 38 34 34 37 36 35 34 33 37 2c 35 32  3,..844765437,52
1590: 31 36 31 35 30 31 36 2c 38 32 39 39 36 32 37 34  1615016,82996274
15a0: 33 2c 32 39 32 32 32 33 31 33 39 2c 31 33 31 36  3,292223139,1316
15b0: 32 31 35 35 33 2c 31 38 38 38 35 30 31 31 39 2c  21553,188850119,
15c0: 37 39 31 37 35 34 37 33 31 2c 38 34 38 35 34 32  791754731,848542
15d0: 31 36 39 2c 31 30 2c 38 2c 0d 0a 31 2c 39 2c 31  169,10,8,..1,9,1
15e0: 30 2c 33 2c 39 2c 34 2c 33 2c 34 2c 34 2c 34 2c  0,3,9,4,3,4,4,4,
15f0: 32 37 38 37 30 30 30 35 39 2c 38 39 35 32 36 39  278700059,895269
1600: 35 34 35 2c 36 37 37 38 33 33 37 36 2c 37 31 31  545,67783376,711
1610: 38 36 34 31 34 35 2c 39 35 36 37 33 34 31 35 32  864145,956734152
1620: 2c 34 32 32 34 30 33 36 32 39 2c 0d 0a 38 31 38  ,422403629,..818
1630: 34 30 35 36 39 2c 33 35 31 37 34 37 36 39 31 2c  40569,351747691,
1640: 31 36 30 37 36 32 32 37 38 2c 33 34 33 33 33 37  160762278,343337
1650: 30 35 31 2c 37 35 36 30 32 36 33 31 33 2c 34 30  051,756026313,40
1660: 37 34 37 34 31 39 38 2c 33 2c 31 2c 32 2c 35 2c  7474198,3,1,2,5,
1670: 36 2c 37 2c 38 2c 39 2c 37 2c 38 2c 31 2c 39 7d  6,7,8,9,7,8,1,9}
1680: 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e  ;...  vector <in
1690: 74 3e 20 70 65 72 69 6f 64 32 28 70 65 72 69 6f  t> period2(perio
16a0: 64 32 5f 2c 20 70 65 72 69 6f 64 32 5f 2b 73 69  d2_, period2_+si
16b0: 7a 65 6f 66 28 70 65 72 69 6f 64 32 5f 29 2f 73  zeof(period2_)/s
16c0: 69 7a 65 6f 66 28 2a 70 65 72 69 6f 64 32 5f 29  izeof(*period2_)
16d0: 29 3b 20 0d 0a 09 69 6e 74 20 74 69 6d 65 32 5f  ); ...int time2_
16e0: 5b 5d 20 3d 20 7b 36 38 32 33 39 30 30 30 31 2c  [] = {682390001,
16f0: 31 38 30 34 39 39 33 37 36 2c 35 37 36 35 36 31  180499376,576561
1700: 31 38 37 2c 39 30 30 31 38 30 38 37 30 2c 38 34  187,900180870,84
1710: 38 37 37 34 39 34 34 2c 33 34 36 38 37 33 39 30  8774944,34687390
1720: 36 2c 32 2c 38 2c 33 2c 31 30 2c 36 2c 35 2c 36  6,2,8,3,10,6,5,6
1730: 39 39 31 34 33 39 36 30 2c 0d 0a 38 31 34 39 36  99143960,..81496
1740: 32 32 30 32 2c 32 35 31 37 36 36 31 30 37 2c 37  2202,251766107,7
1750: 33 32 38 30 37 35 33 31 2c 31 33 31 35 39 35 30  32807531,1315950
1760: 32 32 2c 35 39 38 31 34 37 37 38 34 2c 33 2c 32  22,598147784,3,2
1770: 2c 33 2c 33 2c 37 2c 31 30 2c 36 33 37 39 35 34  ,3,3,7,10,637954
1780: 33 33 36 2c 33 38 30 39 39 37 30 35 32 2c 0d 0a  336,380997052,..
1790: 36 33 36 36 37 35 33 36 37 2c 39 36 38 39 30 38  636675367,968908
17a0: 35 35 34 2c 33 35 34 31 37 32 34 39 34 2c 34 33  554,354172494,43
17b0: 36 33 37 37 33 37 32 2c 31 2c 38 2c 37 2c 37 2c  6377372,1,8,7,7,
17c0: 38 2c 33 2c 34 31 39 37 31 30 32 39 37 2c 31 32  8,3,419710297,12
17d0: 36 38 38 34 32 38 39 2c 35 37 31 31 34 33 34 31  6884289,57114341
17e0: 34 2c 0d 0a 32 36 34 36 33 34 37 39 38 2c 32 36  4,..264634798,26
17f0: 34 38 30 31 31 36 33 2c 31 35 37 36 30 35 38 32  4801163,15760582
1800: 36 2c 34 2c 34 2c 36 2c 38 2c 35 2c 35 2c 34 38  6,4,4,6,8,5,5,48
1810: 35 31 39 39 31 35 36 2c 31 31 37 34 32 30 39 39  5199156,11742099
1820: 35 2c 37 37 33 30 33 34 30 39 39 2c 34 31 39 38  5,773034099,4198
1830: 30 31 35 36 36 2c 0d 0a 36 38 37 36 33 31 33 34  01566,..68763134
1840: 33 2c 34 36 39 32 36 39 34 35 33 2c 34 2c 36 2c  3,469269453,4,6,
1850: 36 2c 37 2c 35 2c 39 2c 34 35 36 33 34 39 39 39  6,7,5,9,45634999
1860: 36 2c 36 39 36 38 32 38 39 39 38 2c 38 34 33 37  6,696828998,8437
1870: 32 35 30 30 33 2c 38 32 39 30 32 37 33 35 32 2c  25003,829027352,
1880: 33 36 39 32 36 37 31 35 36 2c 0d 0a 35 31 35 33  369267156,..5153
1890: 30 39 38 30 32 2c 37 2c 36 2c 38 2c 32 2c 31 30  09802,7,6,8,2,10
18a0: 2c 36 2c 37 35 37 30 30 32 38 32 2c 31 39 31 35  ,6,75700282,1915
18b0: 31 31 30 30 30 2c 35 31 30 30 37 32 33 38 36 2c  11000,510072386,
18c0: 32 39 37 37 33 37 34 31 33 2c 38 31 37 31 32 39  297737413,817129
18d0: 32 36 36 2c 36 36 34 36 30 32 35 34 35 2c 0d 0a  266,664602545,..
18e0: 38 2c 36 2c 31 30 2c 32 2c 36 2c 32 2c 33 32 35  8,6,10,2,6,2,325
18f0: 38 30 32 38 36 32 2c 31 37 31 32 31 34 30 33 36  802862,171214036
1900: 2c 35 30 33 30 39 31 33 30 36 2c 37 32 31 30 39  ,503091306,72109
1910: 33 35 36 2c 39 31 37 34 34 34 37 31 34 2c 37 35  356,917444714,75
1920: 34 39 36 35 32 34 30 2c 31 2c 32 2c 31 30 2c 39  4965240,1,2,10,9
1930: 2c 35 2c 38 7d 3b 0d 0a 09 20 20 76 65 63 74 6f  ,5,8};...  vecto
1940: 72 20 3c 69 6e 74 3e 20 74 69 6d 65 32 28 74 69  r <int> time2(ti
1950: 6d 65 32 5f 2c 20 74 69 6d 65 32 5f 2b 73 69 7a  me2_, time2_+siz
1960: 65 6f 66 28 74 69 6d 65 32 5f 29 2f 73 69 7a 65  eof(time2_)/size
1970: 6f 66 28 2a 74 69 6d 65 32 5f 29 29 3b 20 0d 0a  of(*time2_)); ..
1980: 09 6c 6f 6e 67 20 6c 6f 6e 67 20 5f 5f 5b 5d 20  .long long __[] 
1990: 3d 20 7b 36 37 33 33 31 38 31 34 35 36 31 33 35  = {6733181456135
19a0: 37 30 30 30 30 2c 20 32 37 32 34 32 37 30 38 39  70000, 272427089
19b0: 39 35 39 34 31 34 38 39 39 2c 20 35 31 34 38 33  959414899, 51483
19c0: 39 33 30 34 33 36 32 38 36 39 32 34 34 2c 20 36  9304362869244, 6
19d0: 33 33 37 38 37 31 31 37 32 38 38 34 31 34 36 33  3378711728841463
19e0: 35 2c 20 34 35 34 34 36 34 37 39 37 38 38 31 36  5, 4544647978816
19f0: 38 38 37 36 36 2c 20 32 30 34 37 36 32 35 32 38  88766, 204762528
1a00: 35 32 34 39 36 34 30 36 30 2c 20 35 30 34 30 38  524964060, 50408
1a10: 30 38 35 34 37 32 39 32 30 34 32 36 36 2c 20 37  0854729204266, 7
1a20: 33 37 38 34 37 36 33 37 31 32 30 31 30 34 2c 20  37847637120104, 
1a30: 32 35 34 30 38 31 35 33 35 37 39 32 34 32 38 34  2540815357924284
1a40: 30 30 2c 20 36 34 38 30 31 37 37 32 37 39 32 36  00, 648017727926
1a50: 30 32 38 34 33 37 2c 20 38 37 37 38 36 37 30 35  028437, 87786705
1a60: 35 38 35 37 35 30 36 30 30 2c 20 32 38 38 38 34  585750600, 28884
1a70: 37 33 36 32 38 39 37 36 39 32 33 32 2c 20 33 30  736289769232, 30
1a80: 34 34 30 36 33 32 38 33 38 30 38 30 34 30 32 34  4406328380804024
1a90: 2c 20 35 34 35 38 38 34 30 31 31 34 33 38 35 31  , 54588401143851
1aa0: 39 34 34 2c 20 31 32 30 31 30 30 39 39 32 37 32  944, 12010099272
1ab0: 31 38 30 37 31 37 36 2c 20 31 36 35 38 35 38 31  1807176, 1658581
1ac0: 39 38 31 33 37 31 34 32 36 32 38 2c 20 33 37 32  98137142628, 372
1ad0: 38 34 35 33 39 36 30 38 30 35 30 32 37 38 36 2c  845396080502786,
1ae0: 20 32 32 33 34 37 37 39 37 36 34 39 39 31 32 36   223477976499126
1af0: 32 34 2c 20 33 39 34 31 37 31 32 33 33 33 37 36  24, 394171233376
1b00: 36 37 32 34 38 38 2c 20 32 35 34 36 35 36 39 39  672488, 25465699
1b10: 31 35 32 37 32 35 36 34 31 32 2c 20 36 32 32 30  1527256412, 6220
1b20: 31 39 33 36 35 35 34 31 37 37 35 36 34 35 2c 20  19365541775645, 
1b30: 31 35 34 38 36 37 39 39 30 32 36 32 34 35 36 36  1548679902624566
1b40: 34 2c 20 33 35 38 36 36 38 35 33 32 38 39 36 38  4, 3586685328968
1b50: 37 31 37 33 32 2c 20 33 35 37 36 30 38 30 37 35  71732, 357608075
1b60: 34 38 39 33 33 32 36 37 2c 20 35 32 32 34 35 36  48933267, 522456
1b70: 39 33 30 33 37 31 36 32 38 30 34 35 2c 20 31 35  930371628045, 15
1b80: 38 39 32 37 33 34 39 32 36 36 37 36 37 33 32 39  8927349266767329
1b90: 2c 20 31 35 38 34 36 33 34 33 34 34 38 31 35 33  , 15846343448153
1ba0: 38 38 33 36 2c 20 31 34 31 34 36 39 35 31 33 32  8836, 1414695132
1bb0: 38 32 33 35 31 33 39 37 2c 20 32 36 31 38 33 31  82351397, 261831
1bc0: 38 35 36 31 33 32 39 36 38 30 30 35 2c 20 34 37  856132968005, 47
1bd0: 37 34 39 38 30 36 31 36 30 35 32 30 33 34 35 2c  749806160520345,
1be0: 20 31 2c 20 34 32 33 38 36 37 39 35 38 35 2c 20   1, 4238679585, 
1bf0: 34 33 37 30 38 37 32 32 31 38 2c 20 33 37 35 37  4370872218, 3757
1c00: 30 33 32 34 31 34 2c 20 34 34 31 32 35 39 33 32  032414, 44125932
1c10: 37 36 2c 20 34 39 36 32 37 30 38 34 34 38 2c 20  76, 4962708448, 
1c20: 31 36 37 38 38 34 31 31 38 34 2c 20 36 37 31 35  1678841184, 6715
1c30: 33 31 34 31 36 2c 20 32 38 35 35 37 31 37 30 36  31416, 285571706
1c40: 35 2c 20 34 34 37 36 38 32 38 32 31 35 2c 20 34  5, 4476828215, 4
1c50: 32 36 30 39 36 38 32 36 32 2c 20 33 35 39 31 34  260968262, 35914
1c60: 31 34 37 34 35 2c 20 33 34 39 33 32 32 30 31 36  14745, 349322016
1c70: 34 2c 20 31 37 31 37 38 34 37 33 39 37 2c 20 34  4, 1717847397, 4
1c80: 32 35 33 37 39 32 37 35 31 2c 20 36 38 35 39 33  253792751, 68593
1c90: 31 36 38 32 34 2c 20 34 38 34 35 33 31 38 38 36  16824, 484531886
1ca0: 35 2c 20 33 31 33 38 36 33 37 30 34 2c 20 32 38  5, 313863704, 28
1cb0: 32 39 31 34 33 38 32 37 36 32 38 33 33 36 30 35  2914382762833605
1cc0: 2c 20 34 35 36 36 31 35 31 33 35 36 31 34 35 38  , 45661513561458
1cd0: 34 30 36 2c 20 33 35 30 38 32 34 33 37 38 37 30  406, 35082437870
1ce0: 37 39 37 32 32 36 32 2c 20 34 36 38 31 34 38 34  7972262, 4681484
1cf0: 34 34 36 32 38 38 33 36 39 35 2c 20 35 38 30 38  4462883695, 5808
1d00: 38 37 31 39 31 31 31 39 35 32 36 34 35 34 2c 20  87191119526454, 
1d10: 32 34 34 37 37 37 39 39 32 37 31 33 32 39 31 32  2447779927132912
1d20: 33 32 2c 20 32 34 38 39 38 38 38 32 32 39 2c 20  32, 2489888229, 
1d30: 33 30 39 33 30 33 35 35 31 32 2c 20 38 35 31 33  3093035512, 8513
1d40: 39 35 35 32 32 2c 20 31 38 30 31 35 38 32 34 36  95522, 180158246
1d50: 34 2c 20 33 35 39 37 38 32 37 30 35 36 2c 20 36  4, 3597827056, 6
1d60: 37 38 38 33 33 37 33 35 32 2c 20 34 35 36 33 34  788337352, 45634
1d70: 39 39 39 35 30 2c 20 35 35 37 34 36 33 31 39 37  99950, 557463197
1d80: 36 2c 20 38 37 30 39 36 32 39 32 38 2c 20 37 34  6, 870962928, 74
1d90: 36 31 32 34 36 31 35 39 2c 20 33 36 39 32 36 37  61246159, 369267
1da0: 31 35 35 30 2c 20 31 35 34 35 39 32 39 34 30 33  1550, 1545929403
1db0: 2c 20 37 31 37 37 38 33 36 35 36 2c 20 31 39 34  , 717783656, 194
1dc0: 31 33 39 33 34 36 30 2c 20 31 31 34 34 35 37 31  1393460, 1144571
1dd0: 32 34 30 2c 20 36 39 32 34 33 32 32 31 38 38 2c  240, 6924322188,
1de0: 20 35 30 32 37 30 39 32 37 33 2c 20 36 36 33 38   502709273, 6638
1df0: 31 37 37 34 39 2c 20 32 31 30 39 37 36 37 32 37  17749, 210976727
1e00: 38 31 30 31 36 35 37 39 2c 20 31 37 31 34 35 33  81016579, 171453
1e10: 39 36 34 39 33 37 32 32 35 34 35 35 2c 20 33 34  964937225455, 34
1e20: 35 37 34 34 32 38 32 35 39 36 37 31 37 36 30 2c  574428259671760,
1e30: 20 32 31 31 39 34 38 35 38 38 32 32 37 38 39 32   211948588227892
1e40: 37 34 30 2c 20 37 38 31 37 37 35 34 37 34 34 32  740, 78177547442
1e50: 34 31 35 38 32 38 30 2c 20 32 38 30 37 33 30 35  4158280, 2807305
1e60: 32 36 34 32 38 32 33 32 31 37 36 2c 20 35 37 32  26428232176, 572
1e70: 38 38 33 39 38 33 2c 20 31 37 35 38 37 33 38 34  883983, 17587384
1e80: 35 35 2c 20 31 34 34 36 38 36 30 35 30 32 2c 20  55, 1446860502, 
1e90: 33 34 33 33 33 37 30 35 31 2c 20 33 37 38 30 31  343337051, 37801
1ea0: 33 31 35 36 35 2c 20 34 30 37 34 37 34 31 39 38  31565, 407474198
1eb0: 2c 20 39 37 37 34 30 38 35 38 33 2c 20 31 37 31  , 977408583, 171
1ec0: 32 31 34 30 34 33 2c 20 31 30 30 36 31 38 32 36  214043, 10061826
1ed0: 31 30 2c 20 33 36 30 35 34 36 37 37 35 2c 20 35  10, 360546775, 5
1ee0: 35 30 34 36 36 38 32 37 38 2c 20 35 32 38 34 37  504668278, 52847
1ef0: 35 36 36 37 33 2c 20 34 35 2c 20 39 2c 20 36 33  56673, 45, 9, 63
1f00: 2c 20 36 34 2c 20 34 35 2c 20 36 33 20 7d 3b 0d  , 64, 45, 63 };.
1f10: 0a 09 20 20 76 65 63 74 6f 72 3c 6c 6f 6e 67 20  ..  vector<long 
1f20: 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20 5f 5f 2b 73  long> _(__, __+s
1f30: 69 7a 65 6f 66 28 5f 5f 29 2f 73 69 7a 65 6f 66  izeof(__)/sizeof
1f40: 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e 44 0d 0a 2f  (*__)); ..END../
1f50: 2a 0d 0a 43 41 53 45 28 34 29 0d 0a 09 69 6e 74  *..CASE(4)...int
1f60: 20 70 65 72 69 6f 64 31 5f 5b 5d 20 3d 20 3b 0d   period1_[] = ;.
1f70: 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e  ..  vector <int>
1f80: 20 70 65 72 69 6f 64 31 28 70 65 72 69 6f 64 31   period1(period1
1f90: 5f 2c 20 70 65 72 69 6f 64 31 5f 2b 73 69 7a 65  _, period1_+size
1fa0: 6f 66 28 70 65 72 69 6f 64 31 5f 29 2f 73 69 7a  of(period1_)/siz
1fb0: 65 6f 66 28 2a 70 65 72 69 6f 64 31 5f 29 29 3b  eof(*period1_));
1fc0: 20 0d 0a 09 69 6e 74 20 74 69 6d 65 31 5f 5b 5d   ...int time1_[]
1fd0: 20 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20   = ;...  vector 
1fe0: 3c 69 6e 74 3e 20 74 69 6d 65 31 28 74 69 6d 65  <int> time1(time
1ff0: 31 5f 2c 20 74 69 6d 65 31 5f 2b 73 69 7a 65 6f  1_, time1_+sizeo
2000: 66 28 74 69 6d 65 31 5f 29 2f 73 69 7a 65 6f 66  f(time1_)/sizeof
2010: 28 2a 74 69 6d 65 31 5f 29 29 3b 20 0d 0a 09 69  (*time1_)); ...i
2020: 6e 74 20 70 65 72 69 6f 64 32 5f 5b 5d 20 3d 20  nt period2_[] = 
2030: 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e  ;...  vector <in
2040: 74 3e 20 70 65 72 69 6f 64 32 28 70 65 72 69 6f  t> period2(perio
2050: 64 32 5f 2c 20 70 65 72 69 6f 64 32 5f 2b 73 69  d2_, period2_+si
2060: 7a 65 6f 66 28 70 65 72 69 6f 64 32 5f 29 2f 73  zeof(period2_)/s
2070: 69 7a 65 6f 66 28 2a 70 65 72 69 6f 64 32 5f 29  izeof(*period2_)
2080: 29 3b 20 0d 0a 09 69 6e 74 20 74 69 6d 65 32 5f  ); ...int time2_
2090: 5b 5d 20 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f  [] = ;...  vecto
20a0: 72 20 3c 69 6e 74 3e 20 74 69 6d 65 32 28 74 69  r <int> time2(ti
20b0: 6d 65 32 5f 2c 20 74 69 6d 65 32 5f 2b 73 69 7a  me2_, time2_+siz
20c0: 65 6f 66 28 74 69 6d 65 32 5f 29 2f 73 69 7a 65  eof(time2_)/size
20d0: 6f 66 28 2a 74 69 6d 65 32 5f 29 29 3b 20 0d 0a  of(*time2_)); ..
20e0: 09 6c 6f 6e 67 20 6c 6f 6e 67 20 5f 5f 5b 5d 20  .long long __[] 
20f0: 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72 3c 6c  = ;...  vector<l
2100: 6f 6e 67 20 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20  ong long> _(__, 
2110: 5f 5f 2b 73 69 7a 65 6f 66 28 5f 5f 29 2f 73 69  __+sizeof(__)/si
2120: 7a 65 6f 66 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e  zeof(*__)); ..EN
2130: 44 0d 0a 43 41 53 45 28 35 29 0d 0a 09 69 6e 74  D..CASE(5)...int
2140: 20 70 65 72 69 6f 64 31 5f 5b 5d 20 3d 20 3b 0d   period1_[] = ;.
2150: 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e 74 3e  ..  vector <int>
2160: 20 70 65 72 69 6f 64 31 28 70 65 72 69 6f 64 31   period1(period1
2170: 5f 2c 20 70 65 72 69 6f 64 31 5f 2b 73 69 7a 65  _, period1_+size
2180: 6f 66 28 70 65 72 69 6f 64 31 5f 29 2f 73 69 7a  of(period1_)/siz
2190: 65 6f 66 28 2a 70 65 72 69 6f 64 31 5f 29 29 3b  eof(*period1_));
21a0: 20 0d 0a 09 69 6e 74 20 74 69 6d 65 31 5f 5b 5d   ...int time1_[]
21b0: 20 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20   = ;...  vector 
21c0: 3c 69 6e 74 3e 20 74 69 6d 65 31 28 74 69 6d 65  <int> time1(time
21d0: 31 5f 2c 20 74 69 6d 65 31 5f 2b 73 69 7a 65 6f  1_, time1_+sizeo
21e0: 66 28 74 69 6d 65 31 5f 29 2f 73 69 7a 65 6f 66  f(time1_)/sizeof
21f0: 28 2a 74 69 6d 65 31 5f 29 29 3b 20 0d 0a 09 69  (*time1_)); ...i
2200: 6e 74 20 70 65 72 69 6f 64 32 5f 5b 5d 20 3d 20  nt period2_[] = 
2210: 3b 0d 0a 09 20 20 76 65 63 74 6f 72 20 3c 69 6e  ;...  vector <in
2220: 74 3e 20 70 65 72 69 6f 64 32 28 70 65 72 69 6f  t> period2(perio
2230: 64 32 5f 2c 20 70 65 72 69 6f 64 32 5f 2b 73 69  d2_, period2_+si
2240: 7a 65 6f 66 28 70 65 72 69 6f 64 32 5f 29 2f 73  zeof(period2_)/s
2250: 69 7a 65 6f 66 28 2a 70 65 72 69 6f 64 32 5f 29  izeof(*period2_)
2260: 29 3b 20 0d 0a 09 69 6e 74 20 74 69 6d 65 32 5f  ); ...int time2_
2270: 5b 5d 20 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f  [] = ;...  vecto
2280: 72 20 3c 69 6e 74 3e 20 74 69 6d 65 32 28 74 69  r <int> time2(ti
2290: 6d 65 32 5f 2c 20 74 69 6d 65 32 5f 2b 73 69 7a  me2_, time2_+siz
22a0: 65 6f 66 28 74 69 6d 65 32 5f 29 2f 73 69 7a 65  eof(time2_)/size
22b0: 6f 66 28 2a 74 69 6d 65 32 5f 29 29 3b 20 0d 0a  of(*time2_)); ..
22c0: 09 6c 6f 6e 67 20 6c 6f 6e 67 20 5f 5f 5b 5d 20  .long long __[] 
22d0: 3d 20 3b 0d 0a 09 20 20 76 65 63 74 6f 72 3c 6c  = ;...  vector<l
22e0: 6f 6e 67 20 6c 6f 6e 67 3e 20 5f 28 5f 5f 2c 20  ong long> _(__, 
22f0: 5f 5f 2b 73 69 7a 65 6f 66 28 5f 5f 29 2f 73 69  __+sizeof(__)/si
2300: 7a 65 6f 66 28 2a 5f 5f 29 29 3b 20 0d 0a 45 4e  zeof(*__)); ..EN
2310: 44 0d 0a 2a 2f 0d 0a 7d 0d 0a 2f 2f 20 45 4e 44  D..*/..}..// END
2320: 20 43 55 54 20 48 45 52 45 0d 0a                  CUT HERE..