1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 `#include #include #include #include #include #include //#include #define ll long long using namespace std; const ll SEARCH_TO = 400000000LL; const int ARRAY_SIZE = 1872209; ll n; int k; int P[100]; ll searchCalls =0; int vals[ARRAY_SIZE]; int valsSize =0; void genit(ll left,ll sofar, int pos){ if(pos==k) { vals[valsSize++]= sofar; // assert(valsSize<=ARRAY_SIZE); return; } ll mul = 1; while(left/mul >= 1) { genit(left/mul, sofar*mul, pos+1); mul *= P[pos]; } } ll doit(ll left, ll pos){ if(pos==k)return 1; if(left < SEARCH_TO) { searchCalls++; int a =0;int b = valsSize; while(a!=b) { int c = (a+b)/2; if(vals[c]>left){ b = c; }else { a=c+1; } } if(a==0)return 1; return vals[a-1]; } ll mul = 1; ll res = 1; while(left/mul >= 1) { ll r = mul * doit(left/mul, pos+1); res = max(res, r); mul *= P[pos]; } return res; } ll brut() { genit(SEARCH_TO, 1, 0); cerr << "generated "<> k >> n; for(int i=0;i> P[i]; ll res = good(); cout <