Advertisement
BaoJIaoPisu

Untitled

Aug 29th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pb push_back
  5. #define pf push_front
  6. #define popb pop_back
  7. #define popf pop_front
  8. #define ins insert
  9. #define pq priority_queue
  10. #define minele min_element
  11. #define maxele max_element
  12. #define lb lower_bound //first pos >= val
  13. #define ub upper_bound // first pos > val
  14. #define cnt_bit __builtin_popcount
  15. #define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  16. //#pragma GCC optimize("Ofast")
  17. //#pragma GCC target("avx,avx2,fma")
  18. using namespace std;
  19.  
  20. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  21.  
  22. typedef long long ll;
  23. typedef unsigned long long ull;
  24. typedef pair<ll, ll> pll;
  25. typedef pair<int, int> pii;
  26.  
  27.  
  28. int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1};
  29. int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  30. int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  31.  
  32. const ll oo = 1e18;
  33. const ll maxN = 1e6;
  34. const ull INF = 1e19;
  35.  
  36. /* Author : Le Ngoc Bao Anh, 10A5, LQD High School for Gifted Student */
  37.  
  38. void maximize(int &a, int b) {
  39.     a = max(a, b);
  40. }
  41.  
  42. void minimize(int &a, int b) {
  43.     a = min(a, b);
  44. }
  45.  
  46. ull prime[200];
  47. ull cnt[200];
  48. ull LOG[200];
  49. ull ans;
  50.  
  51. ull C(ull n, ull k) {
  52.     ull ans = 1;
  53.     if(k < n - k) k = n - k;
  54.     for(ull i = n; i >= k + 1; i--) ans *= i;
  55.     for(ull i = 1; i <= n - k; i++) ans /= i;
  56.     return ans;
  57. }
  58.  
  59. void f(ull n, ull prev, ull id, ull x, ull tot, ull num = 0) {
  60.     if(x > INF || x <= 0 || id > 20) return;
  61.     if(tot == n) {
  62.         ans = min(ans, x);
  63.         return;
  64.     }
  65.     if(tot > n || tot <= 0) return;
  66.  
  67.     ull mul = 1;
  68.     prev = min(prev, LOG[id] - 10);
  69.     for(int i = 1; i <= prev; i++) {
  70.         mul = mul * prime[id];
  71.         ull new_add = tot * C(num + i, i);
  72.         f(n, i, id + 1, x * mul, new_add, num + i);
  73.     }
  74. }
  75.  
  76. void solve(ull n) {
  77.     ans = INF;
  78.     f(n, 60, 1, 1, 1, 0);
  79.     if(n == 1) ans = 2;
  80.     LOG[1] = 60;
  81.     LOG[2] = 40;
  82.     LOG[3] = 27;
  83.     LOG[4] = 22;
  84.     LOG[5] = 18;
  85.     LOG[6] = 17;
  86.     LOG[7] = 15;
  87.     LOG[8] = 15;
  88.     LOG[9] = 14;
  89.     LOG[10] = 12;
  90.     LOG[11] = 12;
  91.     LOG[13] = 12;
  92.     LOG[14] = 11;
  93.     LOG[15] = 11;
  94.     LOG[16] = 11;
  95.     LOG[17] = LOG[18] = LOG[19] = LOG[20] = 10;
  96.     cout << n << " " << ans << endl;
  97. }
  98.  
  99. int main()
  100. {
  101.     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  102.     #ifndef ONLINE_JUDGE
  103.     freopen("input.txt", "r", stdin);
  104.     freopen("output.txt", "w", stdout);
  105.     #else
  106.     //online
  107.     #endif
  108.  
  109.     int tc = 1, ddd = 0;
  110.     // cin >> tc;
  111.     ull n;
  112.  
  113.     int count = 0;
  114.     for(int i = 2; i <= 100; i++) {
  115.         bool ok = true;
  116.         for(int j = 2; j <= i - 1; j++) if(i % j == 0) ok = false;
  117.         if(ok) {
  118.             count++;
  119.             prime[count] = i;
  120.             if(count == 20) break;
  121.         }
  122.     }
  123.  
  124.     while(cin >> n) {
  125.         //ddd++;
  126.         //cout << "Case #" << ddd << ": ";
  127.         solve(n);
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement