text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; long long f(long long a, long long b, long long c) { if ((b + c) % 2 == 1) return a + b + c - 1; return max(b, c); } int main() { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); long long ans = a + b + c - 1; ans = min(ans, f(a, b, c)); ans = min(ans, f(b, a, c)); ans = min(ans, f(c, a, b)); printf("%I64d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a[6], ans = 10000000000, i, error = 0; for (i = 0; i < 3; i++) { cin >> a[i]; a[i + 3] = a[i]; } for (i = 0; i < 3; i++) { if (a[i + 1] == 0 && a[i + 2] == 0) { cout << "0"; return 0; } else if (abs(a[i + 1] - a[i + 2]) % 2 == 0) { ans = min(ans, abs(a[i + 1] - a[i + 2]) + min(a[i + 1], a[i + 2])); } else { error++; } } if (error == 3) { cout << "-1"; return 0; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000000000LL; long long ff(long long a, long long b, long long c) { if ((a + b) % 2 != 0) return INF; long long x = (a + b) / 2; if (a < b) swap(a, b); long long y = 0, z = (a - b) / 2; return x + y + z; } int main() { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); printf("%I64d\n", min(min(ff(a, b, c), ff(b, c, a)), ff(c, a, b))); return 0; }
#include <bits/stdc++.h> long long int mod = 998244353; long long int inf = 1000000000000000000; using namespace std; mt19937 unlucko(chrono::steady_clock::now().time_since_epoch().count()); int main() { iostream::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int a, b, c; cin >> a >> b >> c; long long int ans = (1LL << 31); if (abs(a - b) % 2 == 0) ans = min(max(a, b), ans); if (abs(a - c) % 2 == 0) ans = min(max(a, c), ans); if (abs(c - b) % 2 == 0) ans = min(max(c, b), ans); cout << ans; }
#include <bits/stdc++.h> using namespace std; long long v[3]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> v[0] >> v[1] >> v[2]; sort(v, v + 3); if (v[0] % 2 == v[1] % 2 && v[1] % 2 == v[2] % 2) { cout << v[1] << "\n"; } else { if (v[0] % 2 == v[1] % 2) { cout << max(v[1], v[0]) << "\n"; } else if (v[1] % 2 == v[2] % 2) { cout << max(v[1], v[2]) << "\n"; } else { cout << max(v[2], v[0]) << "\n"; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long a[4]; int main() { ios::sync_with_stdio(false); cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if ((a[1] - a[0]) % 2 == 0) { cout << a[1]; } else { cout << a[2]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; if (a <= b) { swap(a, b); } if (a <= c) { swap(a, c); } if (b <= c) { swap(b, c); } if ((b + c) % 2 == 0) { cout << b; } else { cout << a; } return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e6 + 100; long long a[10]; int main() { for (int i = 1; i <= 3; i++) { scanf("%I64d", a + i); } sort(a + 1, a + 4); long long ans = 0; if ((a[2] - a[1]) & 1) { ans = a[3]; } else { ans = a[2]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e1) { cout << e1 << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << " " << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << " " << e2 << " " << e3 << endl; } template <class T1, class T2, class T3, class T4> void deb(T1 e1, T2 e2, T3 e3, T4 e4) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl; } template <class T1, class T2, class T3, class T4, class T5> void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl; } template <class T1, class T2, class T3, class T4, class T5, class T6> void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6 << endl; } int main() { long long ar1[10]; while (scanf("%lld%lld%lld", &ar1[0], &ar1[1], &ar1[2]) == 3) { sort(ar1, ar1 + 3); long long ans = 1000000000000; if (ar1[0] == 0) { if (ar1[1] == 0) ans = 0; else ans = min(ans, ar1[2]); } if (ar1[1] == ar1[2]) { ans = min(ans, ar1[1]); } if (ar1[1] == ar1[0]) { ans = min(ans, ar1[1]); } long long n1, n2; if ((ar1[1] - ar1[0]) % 2 == 0) { n1 = (ar1[1] - ar1[0]) / 2; n1 = 2 * n1 + ar1[0]; ans = min(ans, n1); } if ((ar1[2] - ar1[1]) % 2 == 0) { n1 = (ar1[2] - ar1[1]) / 2; n1 = 2 * n1 + ar1[1]; ans = min(ans, n1); } if ((ar1[2] - ar1[0]) % 2 == 0) { n1 = (ar1[2] - ar1[0]) / 2; n1 = 2 * n1 + ar1[0]; ans = min(ans, n1); } deb(ans); } return 0; }
#include <bits/stdc++.h> using namespace std; long long INF = 1000000000000000000LL; long long calc(long long a, long long b, long long c) { if ((a % 2) != (b % 2)) return INF; return max(a, b); } int MAIN() { long long a, b, c; while (cin >> a >> b >> c) { long long ans = INF; ans = min(ans, calc(a, b, c)); ans = min(ans, calc(a, c, b)); ans = min(ans, calc(b, c, a)); cout << ans << endl; } return 0; ; } int main() { ios ::sync_with_stdio(false); cout << fixed << setprecision(16); return MAIN(); }
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T modinverse(T a, T M) { return bigmod(a, M - 2, M); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / gcd(a, b)) * b; } template <class T, class X> inline bool getbit(T a, X i) { T t = 1; return ((a & (t << i)) > 0); } template <class T, class X> inline T setbit(T a, X i) { T t = 1; return (a | (t << i)); } template <class T, class X> inline T resetbit(T a, X i) { T t = 1; return (a & (~(t << i))); } inline long long power(long long a, long long b) { long long multiply = 1; for (int i = (0); i < (b); i++) { multiply *= a; } return multiply; } map<pair<int, int>, int> M; int main() { long long a, b, c, num[5]; cin >> num[0] >> num[1] >> num[2]; long long x, y, z; sort(num, num + 3); if ((num[1] - num[0]) % 2 == 0) { cout << num[1] << "\n"; } else cout << num[2] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if ((a[0] + a[1]) % 2 == 0) cout << a[1] << endl; else cout << a[2] << endl; }
#include <bits/stdc++.h> using namespace std; long long func(long long a, long long b, long long c) { if (a % 2 != b % 2) return (1ll << 60); long long x = min(a + c, b + c); return a + b + c - x; } int main(void) { int i; long long a, b, c; cin >> a >> b >> c; long long ans = (1ll << 60); ans = min(ans, func(a, b, c)); ans = min(ans, func(b, c, a)); ans = min(ans, func(c, a, b)); if (ans == (1ll << 60)) return -1; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16000000") using namespace std; const double pi = acos(-1.0); long long gcd(long long a, long long b) { if (a < 0) a = -a; if (b < 0) b = -b; if (a < b) swap(a, b); while (b) { long long t = b; b = a % b; a = t; } return a; } template <typename T> struct Point { T x, y; Point(T xx = 0, T yy = 0) : x(xx), y(yy) {} }; template <typename T> Point<T> operator+(const Point<T>& a, const Point<T>& b) { return Point<T>(a.first + b.first, a.second + b.second); } template <typename T> Point<T> operator-(const Point<T>& a, const Point<T>& b) { return Point<T>(a.first - b.first, a.second - b.second); } int main() { long long a[3]; for (int i = 0, _i = (3); i < _i; ++i) cin >> a[i]; sort(a, a + 3); long long res = a[0] + a[1] + a[2] - 1; do { if ((a[0] + a[1]) % 2 == 0) { res = min(res, max(a[0], a[1])); } } while (next_permutation(a, a + 3)); cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 1000005; const long long M = 1000000007; long long n, m, cc, len; long long s[5]; int main() { long long sum = 0; for (long long i = 0; i < 3; i++) scanf("%I64d", &s[i]), sum += s[i]; sort(s, s + 3); long long ans = -1; for (long long i = 0; i < 3; i++) for (long long j = i + 1; j < 3; j++) { long long ano = sum - s[i] - s[j]; if ((s[i] + s[j]) % 2 == 0 && ano >= (abs(s[j] - s[i]) / 2)) { if (ans == -1) ans = s[j]; ans = min(ans, s[j]); } } if (ans == -1) ans = s[2]; printf("%I64d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long tmp1, tmp2, tmp3, a[5]; while (~scanf("%lld%lld%lld", &a[0], &a[1], &a[2])) { sort(a, a + 3); tmp1 = 0x3f3f3f3f3f3f3f3f; tmp2 = 0x3f3f3f3f3f3f3f3f; tmp3 = 0x3f3f3f3f3f3f3f3f; if ((a[1] - a[0]) % 2 == 0) { tmp1 = a[1]; } if ((a[2] - a[0]) % 2 == 0) { tmp2 = a[2]; } if ((a[2] - a[1]) % 2 == 0) { tmp3 = a[2]; } printf("%lld\n", min(min(tmp1, tmp2), tmp3)); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long a, b, c, d, e, f, i, j, k; cin >> a >> b >> c; d = (1LL << 31) + 5; if (abs(b - c) % 2 == 0) { d = min(d, max(b, c)); } if (abs(a - c) % 2 == 0) { d = min(d, max(a, c)); } if (abs(b - a) % 2 == 0) { d = min(d, max(b, a)); } if (d == (1LL << 31 + 5)) cout << "-1"; else cout << d; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int a[3]; while (~scanf("%lld %lld %lld", &a[0], &a[1], &a[2])) { sort(a, a + 3); if ((a[1] - a[0]) % 2 == 0) { printf("%lld\n", a[1]); } else printf("%lld\n", a[2]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int n; cin >> n; if (n == 1) cout << "1"; else if (n == 2) cout << "2"; else if (n & 1) cout << n * (n - 1) * (n - 2); else { if (n % 3 == 0) cout << (n - 1) * (n - 2) * (n - 3); else cout << n * (n - 1) * (n - 3); } return 0; }
#include <bits/stdc++.h> int main() { long long int n, s; scanf("%I64d", &n); if (n < 3) printf("%I64d", n); else { if (n % 2 == 0) { if (n % 3 != 0) printf("%I64d", n * (n - 1) * (n - 3)); else printf("%I64d", (n - 1) * (n - 2) * (n - 3)); } else printf("%I64d", n * (n - 1) * (n - 2)); } return 0; }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (!b) return a; return gcd(b, a % b); } int main() { int n; scanf("%d", &n); if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else if (n % 2) printf("%I64d\n", 1LL * n * (n - 1) * (n - 2)); else { long long int x = 1LL * n * (n - 1); long long int ans = 1LL * (n - 1) * (n - 2) * (n - 3); for (int i = n - 1; i >= 1; i--) ans = max(ans, x / gcd(x, i) * i); printf("%I64d\n", ans); } }
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 5; using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long cal(long long n) { long long ans = 0; if (gcd(n, n - 3) == 1) ans = max(ans, n * (n - 1) * (n - 3)); ans = max(ans, (n - 1) * (n - 2) * (n - 3)); return ans; } int main() { long long n; while (scanf("%lld", &n) != EOF) { if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else if (n == 3) printf("6\n"); else if (n == 4) printf("12\n"); else if (n == 5) printf("60\n"); else if (!(n % 2)) printf("%lld\n", cal(n)); else printf("%lld\n", n * (n - 1) * (n - 2)); } return 0; }
#include <bits/stdc++.h> using namespace std; inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if (a.first == b.first) return a.second < b.second; return a.first > b.first; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { return a * b / gcd<T>(a, b); } template <class T> inline T power(T b, T p) { long long ans = 1; while (p--) ans *= b; return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; if (n == 1 || n == 2) cout << n; else if (n % 3 == 0 && n % 2 == 0) cout << (n - 1) * (n - 2) * (n - 3); else if (n % 2 == 0) cout << (n - 1) * (n) * (n - 3); else cout << n * (n - 1) * (n - 2); }
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } int main() { long long n, ans, tot, j; cin >> n, ans = n; for (long long i = n; ((i - 3) * i + 2) * i > ans; i--) { tot = i * i - i; for (j = i - 1; gcd(tot, j) != 1; j--) ; ans = max(ans, tot * j); } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long long nok(long long a, long long b) { long long nok; long long d = a * b; while ((a != 0) && (b != 0)) { if (a > b) { a = a % b; } else if (b >= a) { b = b % a; } } nok = d / (a + b); return nok; } int main() { long long n, i, j, k, y, r = 0; long long NOK3NUM; cin >> n; if (n <= 50) { y = 1; } else { y = n - 50; } for (i = n; i >= y; i--) { for (j = n; j >= y; j--) { for (k = n; k >= y; k--) { NOK3NUM = nok(i, j); NOK3NUM = nok(NOK3NUM, k); r = max(NOK3NUM, r); } } } cout << r; return 0; }
#include <bits/stdc++.h> using namespace std; long long n; unsigned long long sum; int main() { cin >> n; if (n == 1) { cout << 1 << endl; return 0; } else if (n == 2) { cout << 2 << endl; return 0; } else if (n % 2 != 0) sum = n * (n - 1) * (n - 2); else if (n % 2 == 0 && n % 3 == 0) sum = (n - 1) * (n - 2) * (n - 3); else if (n % 2 == 0 && n % 3 != 0) sum = n * (n - 1) * (n - 3); cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 4; const long long MOD = 1e15 + 3; const double eps = 1e-9; set<pair<long long, int> > st; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; if (n == 1) cout << 1; else if (n == 2) cout << 2; else if (n % 2 == 1) cout << n * (n - 1) * (n - 2); else if (n % 3) cout << n * (n - 1) * (n - 3); else cout << (n - 1) * (n - 2) * (n - 3); return 0; }
#include <bits/stdc++.h> using namespace std; bool vis[1000004]; long long fun(long long n) { for (long long i = 2; i <= n; i++) { if (n % i == 0) vis[i] = 1; if ((n - 1) % i == 0) vis[i] = 1; } for (long long i = n - 2; i >= 1; i--) { bool fl = 0; long long j; for (j = 2; j <= i; j++) { if (i % j == 0 && vis[j]) { fl = 1; break; } } if (!fl) return i; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); long long n; cin >> n; if (n < 3) { cout << n; return 0; } if (n % 2) { long long ans = n * (n - 1); long long d = fun(n); cout << ans * d; } else { long long ans1 = (n - 1) * (n - 2) * fun(n - 1); long long ans2 = n * (n - 1) * fun(n); cout << max(ans1, ans2); } }
#include <bits/stdc++.h> using namespace std; long long find_set(long long v, vector<long long> &p) { if (v == p[v]) return v; return p[v] = find_set(p[v], p); } void union_set(long long a, long long b, vector<long long> &p) { a = find_set(a, p); b = find_set(b, p); if (a != b) { p[b] = a; } } bool mysort(pair<long long, long long> a, pair<long long, long long> b) { return a.first >= b.first; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } void solve() { long long n; cin >> n; if (n == 1 || n == 2) { cout << n << endl; return; } if (n == 6) { cout << "60" << endl; return; } if (n % 2 == 0) { cout << max((n - 1) * lcm(n, n - 3), max((n - 1) * lcm(n, n - 2), (n - 1) * (n - 2) * (n - 3))) << endl; return; } cout << n * (n - 1) * (n - 2) << endl; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; t = 1; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return b; return gcd(b % a, a); } bool mod(long double a, long double b) { return a / b - floor(a / b); } long long lcm(long long a, long long b, long long c) { a = a * b / gcd(a, b); c = a * c / gcd(a, c); return c; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long i, j, first, n, a, b, c; cin >> n; if (n <= 2) { cout << n << '\n'; } else if (n % 2 == 1) { a = n; b = n - 1; c = n - 2; a = lcm(a, b, c); cout << a << '\n'; } else { if (n % 3 == 0) { a = n - 2; } else { a = n; } b = n - 1; c = n - 3; c = lcm(a, b, c); cout << c << '\n'; } return 0; }
#include <bits/stdc++.h> int main() { unsigned long long n; unsigned long long answer; scanf("%I64u", &n); if (n < 3) { printf("%lu", n); return 0; } if (n % 2 == 1) { answer = (n) * (n - 1) * (n - 2); } else if (n % 3 != 0) { answer = n * (n - 1) * (n - 3); } else { answer = (n - 1) * (n - 2) * (n - 3); } printf("%I64u\n", answer); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; if (a == 1) cout << "1" << endl; else if (a == 2) cout << "2" << endl; else { if (a % 2 == 0) { if (a % 3 == 0) cout << (a - 1) * (a - 2) * (a - 3) << endl; else cout << a * (a - 1) * (a - 3) << endl; } else { cout << a * (a - 1) * (a - 2) << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n == 1 || n == 2) { cout << n; return 0; } long long ans; if (n % 2 == 0 && n % 3 == 0) ans = (n - 1) * (n - 2) * (n - 3); else if (n % 2 == 0 && n % 3 != 0) ans = (n) * (n - 1) * (n - 3); else ans = n * (n - 1) * (n - 2); cout << ans; }
#include <bits/stdc++.h> using namespace std; const int LIM = 1e+6, INF = 1e+9; const double PI = 22 / 7; int n; long long ans = 1; long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); } int main() { cin >> n; for (int i = n; i > 1; i--) { long long a = i, b = 1, c = 1; int j = i - 1; while (j > 1) { if (gcd(a, j) == 1) { b = j; break; } else { --j; } } while (j > 1) { if (gcd(a, j) == 1 && gcd(b, j) == 1) { c = j; break; } else { --j; } } ans = max(ans, a * b * c); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, c; cin >> n; if (n == 1) cout << 1 << endl; else if (n == 2) cout << 2 << endl; else if (n % 2 == 1) cout << n * (n - 1) * (n - 2) << endl; else if (n % 3 == 0) cout << (n - 2) * (n - 1) * (n - 3) << endl; else cout << n * (n - 1) * (n - 3) << endl; return 0; }
#include <bits/stdc++.h> int main() { long long n; while (scanf("%I64d", &n) != EOF) { long long ans = 1; if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else { if (n & 1) { ans = n * (n - 1) * (n - 2); } else { if (!(n % 3)) ans = (n - 1) * (n - 2) * (n - 3); else ans = n * (n - 1) * (n - 3); } printf("%I64d\n", ans); } } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long A, long long B) { if (A < B) return gcd(B, A); if (B == 0) return A; return gcd(B, A % B); } long long lcm(long long A, long long B) { long long Tmp = gcd(A, B); return ((A / Tmp) * B); } int main() { ios::sync_with_stdio(false); long long N; cin >> N; long long MX = 1; for (long long i = max(1LL, N - 100); i <= N; i++) for (long long j = max(1LL, N - 100); j <= N; j++) for (long long k = max(1LL, N - 100); k <= N; k++) { long long Tmp = lcm(i, j); MX = max(MX, lcm(Tmp, k)); } cout << MX << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if (n >= 3) { if (n % 2 == 1) cout << n * (n - 1) * (n - 2) << endl; else { if ((n / 2) % 3 == 0) cout << (n - 1) * (n - 2) * (n - 3) << endl; else cout << n * (n - 1) * (n - 3) << endl; } } else cout << n << endl; return 0; }
#include <bits/stdc++.h> int main() { long long n; scanf("%I64d", &n); printf("%I64d", n < 3 ? n : n % 2 ? (n * (n - 1) * (n - 2)) : n % 3 ? (n * (n - 1) * (n - 3)) : (n - 1) * (n - 2) * (n - 3)); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; { if (n <= 2) printf("%lld\n", n); else if (n % 2 == 0) { if (n % 3 == 0) printf("%lld\n", (n - 1) * (n - 2) * (n - 3)); else printf("%lld\n", n * (n - 1) * (n - 3)); } else { printf("%lld\n", n * (n - 1) * (n - 2)); } } }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, MAXN = 1000000 + 10, MAXNUM = 1000000; int prime[MAXN], isprime[MAXN]; int p[MAXN][7], plen[MAXN]; void get_prime() { memset(isprime, 1, sizeof(isprime)); isprime[1] = false; int len = sqrt(MAXNUM + 0.5); for (int i = 2; i <= len; i++) { if (!isprime[i]) continue; for (int j = i * i; j <= MAXNUM; j += i) isprime[j] = false; } } void get_dqf() { int len = sqrt(MAXNUM + 0.5); for (int i = 2; i <= MAXNUM; i++) { if (prime[i]) continue; for (int j = i; j <= MAXNUM; j += i) prime[j] = 1, p[j][plen[j]++] = i; } } bool ok(int n, int a, int b) { for (int i = 0; i < plen[a]; i++) { for (int j = 0; j < plen[n]; j++) if (p[a][i] == p[n][j]) return false; } for (int i = 0; i < plen[b]; i++) { for (int j = 0; j < plen[n]; j++) if (p[b][i] == p[n][j]) return false; } return true; } long long get_max(int n) { long long ans = (long long)n * (n - 1); for (int i = n - 2; i >= 1; i--) { if (ok(i, n, n - 1)) return ans * i; } return -1; } int main() { get_dqf(); get_prime(); int n; while (~scanf("%d", &n)) { if (n < 3) { printf("%d\n", n); continue; } long long ans = 0; for (int i = n; i >= 3; i--) { ans = max(ans, get_max(i)); if (isprime[i]) break; } printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> const int factor_N = 10000005; const int tree_arr_N = 1000005; template <class T> void chkmax(T& a, T b) { a > b ? (a = a) : (a = b); } template <class T> void chkmin(T& a, T b) { a > b ? (a = b) : (a = a); } template <class T> T min(T a, T b) { return a > b ? b : a; } template <class T> T max(T a, T b) { return a < b ? b : a; } template <class T> inline bool rd(T& ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return true; } template <class T> inline void print(T x) { if (x > 9) print(x / 10); putchar(x % 10 + '0'); return; } using std::cin; using std::cout; using std::priority_queue; using std::queue; using std::set; using std::stack; using std::string; using std::vector; long long n, res; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { rd(n); if (n & 1) res = n * (n - 1) * (n - 2); else if (n == 2) res = n; else { if (gcd(n, n - 3) == 1) res = n * (n - 1) * (n - 3); else res = (n - 1) * (n - 2) * (n - 3); } if (n <= 2) res = n; print(res); puts(""); rd(n); return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* r) -> decltype(cerr << *r); template <class c> char dud(...); struct muu { template <class c> muu& operator<<(const c&) { return *this; } muu& operator()() { return *this; } }; int main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); ; ll n = ({ ll t; cin >> t; t; }); ll s = 1; if (n < 3) s = n; else if (n % 2 != 0) s = n * (n - 1) * (n - 2); else if (n % 3 != 0) s = n * (n - 1) * (n - 3); else s = (n - 1) * (n - 2) * (n - 3); printf("%lld", s); }
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n; cin >> n; if (n == 1 || n == 2) { cout << n; return 0; } if (n % 2) { cout << n * (n - 1) * (n - 2); } else { if (n % 3) { cout << n * (n - 1) * (n - 3); } else { cout << (n - 1) * (n - 2) * (n - 3); } } return 0; }
#include <bits/stdc++.h> using namespace std; long long int lcm(long long int a, long long int b) { long long int c = a * b; while (a != b) { if (a > b) a = a - b; else b = b - a; } return c / a; } int main() { long long int n, sum = 0, max = 0, p, done = 0; cin >> n; if (n == 1 || n == 2) { cout << n; return 0; } if (n == 3) { cout << 6; return 0; } for (int i = 0; i <= 3; i++) { for (int j = 0; j <= 3; j++) { for (int k = 0; k <= 3; k++) { sum = lcm((n - i), lcm((n - j), (n - k))); if (i != j && j != k && i != k && max < sum) { max = sum; } } } } cout << max; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n < 3) { cout << n; } else if (n % 2 != 0) { cout << (n * (n - 1) * (n - 2)); } else if (n % 3 != 0) { cout << (n * (n - 1) * (n - 3)); } else { cout << ((n - 1) * (n - 2) * (n - 3)); } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, m1, k, i, j, x, res, cur; long long usg(long long x, long long y) { if (x == 0 || y == 0) { return x + y; } if (x < y) { return usg(y, x); } return usg(y, x % y); } int main() { cin >> n; if (n == 1) { res = 1; } if (n % 2 == 1) { res = n * (n - 1) * (n - 2); } if (n <= 200) { cur = 1; } else { cur = n - 200; } for (i = cur; i <= n; i++) { for (j = cur; j <= n; j++) { for (x = cur; x <= n; x++) { m = (i * j) / usg(i, j); m1 = (m * x) / usg(m, x); if (m1 > res) { res = m1; } } } } cout << res; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (scanf("%lld", &n) != EOF) { if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else if (n % 2 != 0) printf("%lld\n", n * (n - 1) * (n - 2)); else if (n % 3 == 0) printf("%lld\n", (n - 1) * (n - 2) * (n - 3)); else printf("%lld\n", n * (n - 1) * (n - 3)); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; if (n <= 2) cout << n; else if (n % 2 == 0 && n % 3 == 0) { cout << (n - 1) * (n - 2) * (n - 3); } else if (n % 2 != 0) { cout << (n - 1) * (n - 2) * (n); } else { cout << (n - 1) * (n) * (n - 3); } return 0; }
#include <bits/stdc++.h> int main() { long long int n, a, b, c, ans; scanf("%lld", &n); if (n % 2 != 0) { if (n == 1) { ans = 1; } else { a = n; b = n - 1; c = n - 2; ans = a * b * c; } } else if (n % 2 == 0) { if (n == 2) { ans = 2; } else if (n % 6 == 0) { a = n - 1; b = n - 2; c = n - 3; ans = a * b * c; } else { a = n; b = n - 1; c = n - 3; ans = a * b * c; } } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long i, n, i1, i2, i3, k, j; vector<long long> pr; long long lp[3000000], ans; long long usg(long long A, long long B) { if (A > B) swap(A, B); if (A == 0) return B; if (A == 1) return 1; return usg(A, B % A); } long long usj(long long a, long long b, long long c) { long long know = (a * b) / usg(a, b); know = (know * c) / usg(know, c); return know; } int main() { for (i = 2; i <= 2000000; i++) { if (lp[i] == 0) { lp[i] = i; pr.push_back(i); } for (j = 0; j < pr.size() && pr[j] * i <= 2000000 && pr[j] <= lp[i]; j++) lp[i * pr[j]] = pr[j]; } cin >> n; for (i = 0;; i++) if (pr[i] >= n) break; i--; k = pr[i]; if (n <= 7) { if (n == 1) cout << 1 << endl; if (n == 2) cout << 2 << endl; if (n == 3) cout << 6 << endl; if (n == 4) cout << 12 << endl; if (n == 5) cout << 60 << endl; if (n == 6) cout << 60 << endl; if (n == 7) cout << 210 << endl; return 0; } for (i1 = 0; i1 <= 6; i1++) for (i2 = i1 + 1; i2 <= 6; i2++) for (i3 = i2 + 1; i3 <= 6; i3++) ans = max(ans, usj(n - i1, n - i2, n - i3)); for (i1 = 0; i1 <= 6; i1++) for (i2 = i1 + 1; i2 <= 6; i2++) if (k != n - i1 && k != n - i2) ans = max(ans, usj(n - i1, n - i2, k)); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n == 1 || n == 2) cout << n; else if (n % 2 == 1) cout << n * (n - 1) * (n - 2); else { if (n % 3 == 0) cout << (n - 1) * (n - 2) * (n - 3); else cout << n * (n - 1) * (n - 3); } }
#include <bits/stdc++.h> using namespace std; int n; long long ans = 1; int gcd(int x, int y) { return (y == 0) ? (x) : (gcd(y, x % y)); } int main() { cin >> n; if (n == 1 || n == 2) { cout << n; } else if (n % 2 == 1) { ans = (long long)((long long)n * (n - 1) * (n - 2)); cout << ans; } else { ans = (long long)n * (n - 1) * (n - 3); ans /= (long long)gcd(n, n - 3); long long ans1 = (long long)(n - 3) * (n - 1) * (n - 2); cout << max(ans1, ans); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100010; int main() { long long n; scanf("%lld", &n); if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else if (n % 2) printf("%lld\n", n * (n - 1) * (n - 2)); else if (n % 3 == 0) printf("%lld\n", (n - 1) * (n - 2) * (n - 3)); else printf("%lld\n", n * (n - 1) * (n - 3)); return 0; }
#include <bits/stdc++.h> long long N; long long res; long long gcd(long long a, long long b) { long long c; while (b) { c = a % b; a = b; b = c; } return a; } int main() { long long i, j, k; scanf("%I64d", &N); if (N == 1) return 0 * puts("1"); if (N == 2) return 0 * puts("2"); for (k = 1; (1 << k) <= N; ++k) ; if (k > 5) k = 5; for (i = 3; i <= N; i++) { long long t = i * (i - 1); for (j = i - k; j <= i; j++) { if (j < 0) j = 1; long long v = t / gcd(t, j) * j; if (v > res) res = v; } } printf("%I64d\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const long long INF = 1e18; void solve() { long long n; cin >> n; if (n <= 3) { if (n == 1) { cout << "1"; } else if (n == 2) { cout << "2"; } if (n == 3) { cout << "6"; } return; } long long ans; if (n & 1) { ans = n * (n - 1) * (n - 2); } else { if (n % 3) { ans = n * (n - 1) * (n - 3); } else { ans = (n - 1) * (n - 2) * (n - 3); } } cout << ans; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; for (int i = 1; i <= t; i++) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; long long res, N; long long GCD(long long a, long long b) { while (b != 0) { long long r = a % b; a = b; b = r; } return a; } long long LCM(long long a, long long b) { return a * b / GCD(a, b); } int main(void) { cin >> N; for (int i = N; i >= 1 && i >= N - 100; i--) for (int k = N; k >= 1 && k >= N - 100; k--) for (int z = N; z >= 1 && z >= N - 100; z--) res = max(res, LCM(LCM(i, k), z)); cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if (n == 1 || n == 2) { cout << n << endl; ; } else if (n % 2 != 0) { long long int q2 = n * (n - 1) * (n - 2); cout << q2 << endl; } else if (n % 2 == 0 && n % 3 != 0) { long long int q1 = n * (n - 1) * (n - 3); cout << q1 << endl; } else { long long int q3 = (n - 2) * (n - 1) * (n - 3); cout << q3 << endl; } }
#include <bits/stdc++.h> int main() { long long int n, i, s1, s2, s3; scanf("%lld", &n); if (n == 1) { printf("1\n"); } else if (n == 2) { printf("2\n"); } else if (n == 3) { printf("6\n"); } else if (n == 4) { printf("12\n"); } else if (n == 5 || n == 6) { printf("60\n"); } else { if (n % 2 == 1) { printf("%lld\n", n * (n - 1) * (n - 2)); } else { if (n % 3 != 0) { printf("%lld\n", (n - 1) * n * (n - 3)); } else { printf("%lld\n", (n - 1) * (n - 2) * (n - 3)); } } } return 0; }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int lcm(long long int a, long long int b) { long long int c = gcd(a, b); return a * b / c; } int main() { long long int n; while (scanf("%I64d", &n) != EOF) { if (n == 1) cout << 1 << endl; if (n == 2) cout << 2 << endl; if (n == 3) cout << 6 << endl; if (n == 4) cout << 12 << endl; if (n == 5) cout << 60 << endl; if (n >= 6) { if (n % 2) { cout << n * (n - 1) * (n - 2) << endl; } else { long long int fuck = (n - 1) * (n - 2) * (n - 3); long long int fuckyou = (n - 1) * n; for (long long int i = n - 3; i * fuckyou > fuck; i -= 2) { if (lcm(fuckyou, i) > fuck) { fuck = lcm(fuckyou, i); break; } } cout << fuck << endl; } } } return 0; }
#include <bits/stdc++.h> using namespace std; inline long long max_(long long a, long long b) { return (a > b) ? a : b; } inline long long min_(long long a, long long b) { return (a < b) ? a : b; } long long sqr_root(long long a) { long long x = sqrt(a); return (x * x == a) ? x : -1; } class Compare { public: bool operator()(pair<long long, long long> &a, pair<long long, long long> &b) { return (a.first < b.first) || (a.first == b.first && a.second < b.second); } }; int main() { ios::sync_with_stdio(false); cin.tie(NULL); if (fopen("inp.txt", "r")) { freopen("inp.txt", "r", stdin); freopen("outp.txt", "w", stdout); } long long n; cin >> n; if (n == 1 || n == 2) cout << n << endl; else if (n % 2) { cout << n * (n - 1) * (n - 2); } else { if (n % 3 == 0) { long long x = n * (n - 2) / 2, y = n * (n - 3) / 3, z = (n - 1) * (n - 2) * (n - 3); cout << max_((n - 1) * max_(x, y), z); } else { long long x = n * (n - 2) / 2, y = n * (n - 3), z = (n - 1) * (n - 2) * (n - 3); cout << max_((n - 1) * max_(x, y), z); } } return 0; }
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b == 0) return a; return GCD(b, a % b); } long long max(long long a, long long b) { return a > b ? a : b; } int main() { int n; scanf("%d", &n); if (n == 1) printf("1\n"); else if (n == 2) printf("2\n"); else { long long ans = 0; if (n % 2) { ans = (long long)n * (n - 1) * (n - 2); } else { ans = (long long)(n - 1) * (n - 2) * (n - 3); long long i; for (i = n / 2; i <= n - 2; i++) { ans = max(ans, (long long)n * (n - 1) * i / GCD(n, i)); } } printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, ans; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long max(long long a, long long b) { if (a > b) return a; return b; } int main() { scanf("%I64d", &n); ans = 0; if (n == 1) { printf("1\n"); return 0; } else if (n == 2) { printf("2\n"); return 0; } else if (n == 3) { printf("6\n"); return 0; } else if (n == 4) { printf("12\n"); return 0; } for (int i = 0; i <= 1; ++i) for (int j = i + 1; j <= 2; ++j) for (int k = j + 1; k <= 3; ++k) { long long a = n - i, b = n - j, c = n - k; long long res = lcm(a, b); res = lcm(res, c); ans = max(ans, res); } printf("%I64d\n", ans); }
#include <bits/stdc++.h> using namespace std; unsigned long long t, n, sum1, sum2; int main() { unsigned long long i, j, k; cin >> n; if (n < 3) cout << n; else { if (n % 2) { cout << n * (n - 1) * (n - 2); } else { if (n % 3) cout << n * (n - 1) * (n - 3); else cout << (n - 1) * (n - 2) * (n - 3); } } return 0; }
#include <bits/stdc++.h> unsigned long long gcd(unsigned long long a, unsigned long long b) { return (!b ? a : gcd(b, a % b)); } unsigned long long gcd(unsigned long long a, unsigned long long b, unsigned long long c) { return gcd(a, gcd(b, c)); } unsigned long long nok(unsigned long long a, unsigned long long b) { return a * b / gcd(a, b); } unsigned long long nok(unsigned long long a, unsigned long long b, unsigned long long c) { return nok(a, nok(b, c)); } int main() { unsigned long long n; std::cin >> n; unsigned long long ma, mb, mc; if (n <= 20) { ma = 1; mb = 1; mc = 1; } else { ma = n - 20; mb = ma; mc = ma; } unsigned long long s = 0; for (unsigned long long a = ma; a <= n; ++a) { for (unsigned long long b = mb; b <= n; ++b) { for (unsigned long long c = mc; c <= n; ++c) { if (nok(a, b, c) > s) { s = nok(a, b, c); } } } } std::cout << s << std::endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (scanf("%lld", &n) == 1) { long long res; if (n == 1) res = 1; else if (n == 2) res = 2; else res = n * (n - 1) * (n - 2); if (n % 6 == 0) res = max(res / 2, (n - 1) * (n - 2) * (n - 3)); else if (n % 2 == 0 && n > 2) res = max(res / 2, n * (n - 1) * (n - 3)); printf("%lld\n", res); } return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long int n, c = 1, l; cin >> n; long long int ans = n; if (n == 1 || n == 2) { cout << n; return 0; } if (n % 6 == 0) ans = (n - 1) * (n - 2) * (n - 3); for (int i = (n - 1); (c != 3) && (n % 6 != 0); i--) { l = gcd(n, i); if (l == 1) { ans = ans * i; c++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string str, str2; long long elm, tc, lim, n, m; tc = 1; while (tc--) { cin >> n; if (n == 1) cout << 1; else if (n == 2) cout << 2; else if (n % 2 == 1) cout << n * (n - 1) * (n - 2); else { if (n % 3 == 0) { n--; cout << n * (n - 1) * (n - 2); } else { cout << n * (n - 1) * (n - 3); } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n < 3) cout << n; else { if (n & 1) cout << n * (n - 1) * (n - 2) << endl; else if (n % 3) cout << n * (n - 1) * (n - 3) << endl; else cout << (n - 1) * (n - 2) * (n - 3) << endl; } }
#include <bits/stdc++.h> using namespace std; long long n; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } int main() { cin >> n; if (n <= 2) cout << n << endl; else { if (n & 1) cout << n * (n - 1) * (n - 2) << endl; else { long long tmp = n * (n - 1) * (n - 3) / gcd(n, n - 3); tmp = max(tmp, (n - 1) * (n - 2) * (n - 3)); cout << max(n * (n - 1) * (n - 2) / 2, tmp) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; bool check(int a, int b, int c) { int r1 = 0, r2 = 0; if (a % 3 == 0) r1++; if (b % 3 == 0) r1++; if (c % 3 == 0) r1++; if (a % 2 == 0) r2++; if (b % 2 == 0) r2++; if (c % 2 == 0) r2++; return !(r1 > 1 || r2 > 1); } int main() { long long n; cin >> n; long long ret; if (n == 1) ret = 1; else if (n == 2) ret = 2; else if (n % 2 != 0) ret = n * (n - 1) * (n - 2); else { ret = check(n, n - 1, n - 3) ? n * (n - 1) * (n - 3) : 0; ret = check(n - 1, n - 2, n - 3) ? max(ret, (n - 1) * (n - 2) * (n - 3)) : ret; } cout << ret << endl; }
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b == 0) { return a; } else { return GCD(b, a % b); } } int main() { long long n, i, t; cin >> n; if (n == 1) { cout << 1; exit(0); } if (n == 2) { cout << 2; exit(0); } if (n % 2 != 0) { cout << (n * (n - 1) * (n - 2)); } else { if (n % 3 == 0) { cout << ((n - 1) * (n - 2) * (n - 3)); } else { cout << ((n - 1) * (n - 3) * (n)); } } return 0; }
#include <bits/stdc++.h> using namespace std; const int K = 150; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main(int argc, char *argv[]) { int n; cin >> n; if (n == 1) return cout << 1 << endl, 0; if (n == 2) return cout << 2 << endl, 0; long long ans = 0; int li = max(1, n - K), lj = max(1, n - K), lk = max(1, n - K); for (int i = li; i <= (n); ++i) for (int j = lj; j <= (n); ++j) for (int k = lk; k <= (n); ++k) ans = max(ans, lcm(i, lcm(j, k))); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if (n <= 2) cout << n; else if (n % 2 == 0) { if (n % 3 == 0) cout << (n - 1) * (n - 2) * (n - 3); else cout << n * (n - 1) * (n - 3); } else if (n % 2 == 1) cout << (n * (n - 1) * (n - 2)); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long n; cin >> n; if (n <= 2) { cout << n << '\n'; return 0; } if (n & 1) { cout << (n * (n - 1) * (n - 2)) << '\n'; } else { if (n % 3 == 0) { cout << (n - 1) * (n - 2) * (n - 3); } else { cout << n * (n - 1) * (n - 3); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); long long n; cin >> n; if (n - 2 <= 0) { int res = 1; for (__typeof(n) i = 1; i <= n; i++) res *= i; cout << res; } else if (n % 2) cout << n * (n - 1) * (n - 2); else if (n % 3) cout << n * (n - 1) * (n - 3); else { n--; cout << n * (n - 1) * (n - 2); } return 44 / 77; }
#include <bits/stdc++.h> using namespace std; inline long long IN() { long long x = 0; int ch = getchar(), f = 1; while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar(); if (ch == '-') { f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f; } inline void OUT(long long x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) OUT(x / 10), putchar(x % 10 + '0'); else putchar(x + '0'); } int n; int main() { n = IN(); if (n <= 2) return printf("%d\n", n), 0; if (n & 1) return OUT(1ll * n * (n - 1) * (n - 2)), 0; if (n % 3 == 0) OUT(1ll * (n - 1) * (n - 2) * (n - 3)); else OUT(1ll * n * (n - 1) * (n - 3)); }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n == 2) cout << 2; else if (n == 1) cout << 1; else if (n & 1) cout << n * (n - 1) * (n - 2); else if (n % 3 > 0) cout << n * (n - 1) * (n - 3); else cout << max(n * (n - 1) * (n - 2) / 2, (n - 1) * (n - 2) * (n - 3)); return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long max(long long a, long long b) { return a > b ? a : b; } long long LCM(long long a, long long b) { return a * b / gcd(a, b); } int num[10]; int main() { long long N, ans, t; long long i, j; num[1] = 1; num[2] = 2; num[3] = 6; num[4] = 12; num[5] = 60; num[6] = 60; while (scanf("%I64d", &N) != EOF) { ans = 0; if (N < 7) { printf("%d\n", num[N]); continue; } for (i = N; i >= 3; i--) { t = i * (i - 1); if (i & 1) t = LCM(t, (i - 2)); else t = LCM(t, (i - 3)); ans = max(ans, t); } printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; double tick() { static clock_t oldt, newt = clock(); double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC; oldt = newt; return diff; } long long mod(long long n, long long m = 1000000007) { if (n < 0) { return (m - abs(n) % m) % m; } else return n % m; } long long power(long long a, long long n) { if (n == 0) return 1; if (n == 1) return a; if (n == 2) return a * a; if (n & 1) { n--; return a * power(power(a, 2), n / 2); } else return power(power(a, 2), n / 2); } vector<long long> isPrime(1000001, true), prime, spf(1000001); void sieve(long long n) { isPrime[0] = isPrime[1] = false; for (long long i = 2; i < n; i++) { if (isPrime[i]) { prime.push_back(i); spf[i] = i; } for (long long j = 0; j < prime.size() && i * prime[j] < n && prime[j] <= spf[i]; j++) { isPrime[i * prime[j]] = false; spf[i * prime[j]] = prime[j]; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t = 1; while (t--) { long long n; cin >> n; if (n < 3) cout << n << '\n'; else if (n & 1) cout << n * (n - 1) * (n - 2) << '\n'; else { long long ans = 0; if (n % 3 == 0) ans = (n - 2) * (n - 1) * (n - 3); else ans = (n) * (n - 1) * (n - 3); cout << ans << '\n'; } } cerr << "\nExecution time: " << tick() * 1000 << " ms" << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; } int main(void) { long long N; cin >> N; long long x, y, z; long long ans = 0; for (x = N; x * x * x > ans; x--) for (y = x; x * y * y > ans; y--) for (z = y; x * y * z > ans; z--) { if (gcd(x, y) == 1 && gcd(x, z) == 1 && gcd(y, z) == 1) ans = x * y * z; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> const long long template_array_size = 1e6; const long long INF = 9223372036854775807; const long long MOD = 1e9 + 7; using namespace std; long long n, m, k, x, a, b; long long gcd(long long a, long long b) { long long t; while (b != 0) { t = b; b = a % b; a = t; } return a; } long long lcm(long long a, long long b) { if (a > b) return (a / gcd(a, b)) * b; else return (b / gcd(a, b)) * a; } vector<long long> v, v2; void solve() { cin >> n; if (n < 3) { cout << n; } else { if (n % 2 == 0) { cout << max((n * (n - 1) * (n - 3)) / gcd(n, n - 3), (n - 1) * (n - 2) * (n - 3)); } else { cout << n * (n - 1) * (n - 2); } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; template <typename T> void print(T AA[], long long int nn) { for (long long int ii = 0; ii < nn; ii += 1) { cout << AA[ii] << " "; } cout << "\n"; } template <typename T> inline void print(T nn) { cout << nn << "\n"; } long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n; cin >> n; if (n == 1 || n == 2) { print(n); return 0; } if (n % 2 == 1) { print(n * (n - 1) * (n - 2)); return 0; } long long int ans = (n * (n - 1) * (n - 2)) / 2; for (long long int i = n - 3; i > 0; i -= 1) { long long int temp = gcd(n - 1, i) * gcd(n, i); ans = max(ans, (n * (n - 1) * i) / temp); } print(max(ans, (n - 1) * (n - 2) * (n - 3))); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long x; cin >> x; if (x < 3) cout << x; else if (x % 2 != 0) cout << x * (x - 1) * (x - 2); else if (x % 2 == 0) { if ((x / 2) % 3 == 0) cout << (x - 3) * (x - 1) * (x - 2); else cout << x * (x - 3) * (x - 1); } }
#include <bits/stdc++.h> using namespace std; long long N, i, j, k, a, b; long long gcd(long long a, long long b) { long long t; while (b > 0) { t = b; b = a % b; a = t; } return a; } long long lcm(long long a, long long b, long long c) { long long d = a * b / gcd(a, b); return c * d / gcd(c, d); } int main() { scanf("%I64d", &N); for (i = max(1ll, N - 100); i <= N; i++) { for (j = i; j <= N; j++) { for (k = j; k <= N; k++) { b = lcm(i, j, k); if (b > a) a = b; } } } printf("%I64d\n", a); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200005; void amfetamin() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0); } int gcd(long long a, long long b) { while (b > 0) { long long smurf = a; a = b; b = smurf % b; } return a; } int main() { amfetamin(); long long n; cin >> n; long long sol; if (n == 1) { cout << 1; return 0; } if (n == 2) { cout << 2; return 0; } if (n % 2 == 1) { sol = n * (n - 1) * (n - 2); cout << sol; } else { long long mx = (n - 1) * (n - 2) * (n - 3); long long cur = n * (n - 1); for (long long i = n - 2; i >= 0; i--) { if (gcd(i, n) == 1 && gcd(i, n - 1) == 1) { cur *= i; break; } } cout << (long long)max(mx, cur); } }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { long long n; cin >> n; if (n == 1) cout << 1 << endl; else { long long ans = 1; for (int i = 0; i < (7); i++) if (n - i - 1 >= 1) { for (int a = 1; a <= n; a++) ans = max(ans, lcm((n - i) * (n - i - 1), a)); } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { if (n == 1 || n == 2) { cout << n << endl; continue; } long long ans; if (n & 1) ans = n * (n - 1) * (n - 2); else if (n % 3) ans = n * (n - 1) * (n - 3); else ans = (n - 1) * (n - 2) * (n - 3); cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, sum = 0; cin >> a; if (a == 3) { cout << "6" << endl; return 0; } if (a == 2) { cout << "2" << endl; return 0; } if (a == 1) { cout << "1" << endl; return 0; } if (a % 2) sum = a * (a - 1) * (a - 2); else if (a % 3) sum = a * (a - 1) * (a - 3); else sum = (a - 1) * (a - 2) * (a - 3); cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, pr = 1; int nod(int x, int y) { int r; while (y != 0) { r = x % y; x = y; y = r; } return x; } int main() { cin >> n; if (n == 1) cout << 1 << endl; else if (n == 2) cout << 2 << endl; else if (n % 2 == 1) cout << n * (n - 1) * (n - 2) << endl; else { long long a = n, b = n - 1, c = n - 3; if (n % 3 != 0) cout << a * b * c << endl; else cout << b * (n - 2) * c << endl; } return 0; }
#include <bits/stdc++.h> inline long long read() { long long x = 0, y = 1; char a = getchar(); while (a > '9' || a < '0') { if (a == '-') y = -1; a = getchar(); } while (a >= '0' && a <= '9') { x = (x << 3) + (x << 1) + a - '0'; a = getchar(); } return x * y; } using namespace std; int main() { int n; cin >> n; if (n == 1) putchar('1'), exit(0); else if (n == 2) putchar('2'), exit(0); cout << 1LL * (n - 1) * (n & 1 || n % 3 ? n : 1) * (!(n & 1) ? n - 3 : n - 2) * (!(n & 1) && !(n % 3) ? n - 2 : 1); return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 1000000111; const int MOD = 1000000007; const int S_N = 201; const int S_A = 1000010; template <typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B>& p) { out << "(" << p.first << "," << p.second << ") "; return out; } template <typename A, typename B> void printP(const pair<A, B>& p, const char* str = NULL) { if (str != NULL) cout << str << ":"; cout << "(" << p.first << "," << p.second << ") "; } template <typename T> void printV(const vector<T>& v, const char* str = NULL) { if (str != NULL) cout << str << ": "; for (int i = 0; i < (v.size()); ++i) cout << v[i] << " "; cout << '\n'; } long long nwd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; return nwd(b, a % b); } long long nww(long long a, long long b) { return (a / nwd(a, b)) * (long long)b; } void solve() { long long n; cin >> n; long long maxi = 0; if (n <= 100) { for (int a = 1; a <= (n); ++a) for (int b = 1; b <= (n); ++b) for (int c = 1; c <= (n); ++c) { maxi = max((nww(nww(a, b), c)), (maxi)); } } else { for (int c = 1; c <= (n - 2); ++c) { maxi = max((nww(nww(n, n - 1), c)), (maxi)); if (c < n - 2) maxi = max((nww(nww(n - 1, n - 2), c)), (maxi)); } } cout << maxi << '\n'; } int main() { ios_base::sync_with_stdio(false); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if (n == 1) cout << "1"; else if (n == 2) cout << "2"; else if (n == 3) cout << "6"; else if (n % 2 == 1) { cout << n * (n - 1) * (n - 2); } else { if (n % 3 == 0) cout << (n - 1) * (n - 2) * (n - 3); else cout << n * (n - 1) * (n - 3); } }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { while (a > 0 && b > 0) { if (a > b) a = a % b; else b = b % a; } if (a > 0) return a; if (b > 0) return b; } int main() { long long n; cin >> n; long long low = max(1LL, n - 5); long long ans = 0; for (long long i = low; i <= n; ++i) for (long long j = low; j <= n; ++j) for (long long k = low; k <= n; ++k) { long long lcm = i; lcm = lcm * j / gcd(lcm, j); lcm = lcm * k / gcd(lcm, k); ans = max(ans, lcm); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y, z, i, temp, j, z1, a, b, c = 0; cin >> n; if (n == 1) { cout << 1; return 0; } if (n == 2) { cout << 2; return 0; } x = n; if (x % 6 == 0) x--; for (i = x - 1; i >= 1; i--) { y = i; a = x; while (a > 0) { temp = y % a; y = a; a = temp; } if (y == 1) { y = i; break; } } z1 = x * y; for (j = y - 1; j >= 1; j--) { z = j; b = z1; while (b > 0) { temp = z % b; z = b; b = temp; } if (z == 1) { z = j; break; } } cout << x * y * z; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n <= 2 ? n : n % 2 ? (long long)n * (n - 1) * (n - 2) : n % 3 ? (long long)n * (n - 1) * (n - 3) : (long long)(n - 1) * (n - 2) * (n - 3)) << '\n'; return 0; }
#include <bits/stdc++.h> int main(void) { long long int n, j = 3, i = 0; scanf("%lld", &n); long long int m = n - 3; if (n <= 2) { printf("%lld", n); } else { if (n % 2 == 1) { printf("%lld", n * (n - 1) * (n - 2)); } else { while (m > n / 2) { while (((m % j == 0) && ((n % j == 0) || ((n - 1) % j == 0))) != 1) { if (j + 2 >= m / 2) { if (m * n * (n - 1) > (n - 1) * (n - 2) * (n - 3)) { printf("%lld", m * n * (n - 1)); } else { printf("%lld", (n - 1) * (n - 2) * (n - 3)); } i++; exit(0); } else { j += 2; } } j = 3; m -= 2; } if (i == 0) { if (n < 6) { printf("%lld", n * (n - 1) * (n - 2) / 2); } else { printf("%lld", (n - 1) * (n - 2) * (n - 3)); } } } } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } int main() { long long a, b, c, d, e, i, j, k, ans2 = 0; cin >> a; b = 49; long long t = min(b, a); long long res = 0; for (i = 0; i < t; i++) { for (j = i; j < t; j++) { for (k = j; k < t; k++) { res = max(res, lcm(a - i, lcm(a - j, a - k))); } } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; unsigned long long gcd(unsigned long long a, unsigned long long b) { return b == 0 ? a : gcd(b, a % b); } int32_t main() { unsigned long long n; cin >> n; unsigned long long ans = 0; if (n < 3) { ans = n; } else if (n % 2 != 0) { ans = n * (n - 1) * (n - 2); } else if (n % 3 != 0) { ans = n * (n - 1) * (n - 3); } else { ans = (n - 1) * (n - 2) * (n - 3); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { long long int n; cin >> n; if (n == 1 || n == 2) { cout << n << endl; return 0; } if (n % 2 == 1) { cout << (n * (n - 1) * (n - 2)) << endl; return 0; } if (n == 4 || n == 6) { cout << ((n * (n - 1) * (n - 2)) / 2) << endl; return 0; } if (n % 3 == 0) { cout << ((n - 1) * (n - 2) * (n - 3)) << endl; return 0; } cout << (n * (n - 1) * (n - 3)) << endl; return 0; }