fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long hcf(long a, long b) {
  6. if (a == 0)
  7. return b;
  8. else if (b == 0)
  9. return a;
  10. else {
  11. return hcf(b, a % b);
  12. }
  13. }
  14. long lcm(long a, long b) {
  15. // comment
  16. return a * b / hcf(a, b);
  17. }
  18.  
  19. int main() {
  20. long n;
  21. cin >> n;
  22. if (n == 1)
  23. cout << "1\n";
  24. else if (n == 2)
  25. cout << "2\n";
  26. else if (n == 3)
  27. cout << "6\n";
  28. else if (n % 2 != 0)
  29. cout << n * (n - 1) * (n - 2) << "\n";
  30. else {
  31. long maxv = (n - 1) * (n - 2) * (n - 3);
  32. for (long v1 = n; v1 >= n - 10 && v1 >= 1; v1--) {
  33. for (long v2 = v1 - 1; v2 >= n - 10 && v2 >= 1; v2--) {
  34. for (long v3 = v2 - 1; v3 >= n - 10 && v2 >= 1; v3--) {
  35. long mcl = lcm(lcm(v1, v2), v3);
  36. if (mcl > maxv) {
  37. maxv = mcl;
  38. }
  39. }
  40. }
  41. }
  42. cout << maxv << "\n";
  43. }
  44. }
Success #stdin #stdout 0s 16064KB
stdin
763116
stdout
444394078546562430