fork download
  1. #include <cstring>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <queue>
  9.  
  10. #define rep(i, l, r) for(int i = l; i <= r; i++)
  11. #define down(i, l, r) for(int i = l; i >= r; i--)
  12. #define MS 34567
  13. #define MAX 1037471823
  14.  
  15. using namespace std;
  16.  
  17. int k[11], n;
  18. long long ans, ansm;
  19.  
  20. void Search(long long m, long long s, int o, int l)
  21. {
  22. if (ansm < s || (ansm == s && ans > m)) ans = m, ansm = s; long long a = 1; int b = 1;
  23. if (o == 11) return;
  24. while(m*a <= n && b <= l)
  25. {
  26. Search(m*a, s*b, o+1, b);
  27. a *= k[o]; b++;
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. scanf("%d", &n); ans = ansm = 0;
  34. k[1] = 2, k[2] = 3, k[3] = 5, k[4] = 7, k[5] = 11, k[6] = 13, k[7] = 17, k[8] = 19, k[9] = 23, k[10] = 27;
  35. Search(1, 1, 1, 999);
  36. printf("%lld\n", ans);
  37. return 0;
  38. }
Success #stdin #stdout 0s 3344KB
stdin
1234567890
stdout
1102701600