text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
int main() {
long long int n;
scanf("%lld", &n);
if (n <= 2)
printf("%lld\n", n);
else if (n % 2)
printf("%lld\n", n * (n - 1) * (n - 2));
else if (n % 3 == 0)
printf("%lld\n", (n - 3) * (n - 1) * (n - 2));
else
printf("%lld\n", n * (n - 1) * (n - 3));
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n == 1)
cout << n << endl;
else if (n == 2)
cout << n * (n - 1) << endl;
else if (n % 2) {
cout << n * (n - 1) * (n - 2) << endl;
} else {
long long a = n * (n - 1) * (n - 2) / 2;
long long b = (n - 1) * (n - 2) * (n - 3);
long long c = n * (n - 1) * (n - 3);
if (n % 3 == 0) c /= 3;
cout << max(a, max(b, c)) << endl;
}
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 lcm(int a, int b, int c) {
long long x = (long long)a * (long long)b / (long long)gcd(a, b);
long long res = (long long)c * x / (long long)gcd(c, x);
return res;
}
int main() {
int n;
scanf("%i", &n);
long long maxx = 1;
for (int i = n; i > max(0, n - 75); i--) {
for (int i2 = n; i2 > max(0, n - 75); i2--) {
for (int i3 = n; i3 > max(0, n - 75); i3--) {
maxx = max(maxx, lcm(i, i2, i3));
}
}
}
printf("%lld\n", maxx);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int prime[1000005];
int ans[5];
int idx;
set<int> s, s1;
set<int>::iterator it;
int main() {
int i, j;
for (i = 2; i <= 1000000; i++) {
if (prime[i] == 1) continue;
for (j = i + i; j <= 1000000; j += i) prime[j] = 1;
}
int n;
scanf("%d", &n);
if (n == 1)
printf("1\n");
else if (n == 2)
printf("2\n");
else {
long long sum = n;
for (i = 2; i < n; i++) {
if (n % i == 0) s.insert(i);
}
int countt = 0;
for (i = n - 1; i >= 1; i--) {
bool no = 0;
for (it = s.begin(); it != s.end(); it++) {
if (i % (*it) == 0) {
no = 1;
break;
}
}
if (!no) {
sum *= (long long)i;
countt++;
}
if (countt == 2) break;
}
long long sum1 = n - 1;
for (i = 2; i < n - 1; i++) {
if ((n - 1) % i == 0) s1.insert(i);
}
countt = 0;
for (i = n - 2; i >= 1; i--) {
bool no = 0;
for (it = s1.begin(); it != s1.end(); it++) {
if (i % (*it) == 0) {
no = 1;
break;
}
}
if (!no) {
sum1 *= (long long)i;
countt++;
}
if (countt == 2) break;
}
printf("%I64d\n", max(sum, sum1));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
int MAX = 1000000000;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
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 - 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(false);
cin.tie(NULL);
long long n;
cin >> n;
if (n == 1) {
cout << 1 << endl;
} else if (n == 2) {
cout << 2 << endl;
} else {
long long x = n;
long long y = n - 1;
if (n % 2) {
cout << (n * (n - 1)) * (n - 2) << endl;
} else {
if (n % 3 == 0) {
cout << (n - 1) * (n - 2) * (n - 3) << endl;
} else {
cout << n * (n - 1) * (n - 3) << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long int inf = 1e18;
const long long int ninf = -1e18;
const long long int mod = 1000000007;
const long long int MOD = 998244353;
template <typename T>
bool asc(pair<T, T> &a, pair<T, T> &b) {
if (a.first == b.first) {
return a.second < b.second;
}
return a.first < b.first;
}
template <typename T>
bool desc(pair<T, T> &a, pair<T, T> &b) {
if (a.first == b.first) {
return a.second > b.second;
}
return a.first > b.first;
}
template <typename T>
T power(T a, T b) {
if (b == 0) return 1;
if (b == 1)
return a;
else {
T res = (power(a, b / 2));
if (b % 2) {
return (res * res * a);
} else {
return res * res;
}
}
}
template <typename T>
T power(T a, T b, T modulo) {
if (b == 0) return 1;
if (b == 1)
return a;
else {
T res = (power(a, b / 2, modulo) % modulo);
if (b % 2) {
return ((((res % modulo) * (res % modulo)) % modulo) * (a % modulo)) %
modulo;
} else {
return ((res % modulo) * (res % modulo)) % modulo;
}
}
}
template <typename T>
T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % b);
}
template <typename T>
T lcm(T p, T q) {
return (p * q) / gcd<T>(p, q);
}
template <typename T>
void primefactorise(T n, vector<T> &vec) {
while (n % 2 == 0) {
vec.emplace_back(2);
n = n / 2;
}
for (int i = 3; i <= sqrt(n); i = i + 2) {
while (n % i == 0) {
vec.emplace_back(i);
n = n / i;
}
}
if (n > 2) {
vec.emplace_back(n);
}
}
template <typename T>
void all_factor(T n, vector<T> &vec) {
for (auto i = 1; i <= sqrt(n); ++i) {
if (n % i == 0) {
vec.emplace_back(i);
if (i != (n / i)) {
vec.emplace_back(n / i);
}
}
}
}
long long mulmod(long long a, long long b, long long c) {
if (b == 0) {
return 0;
}
long long s = mulmod(a, b / 2, c);
if (b % 2 == 1) {
long long p = (a % c + 2 * (s % c)) % c;
return p;
} else {
long long p = (2 * (s % c)) % c;
return p;
}
}
long long mod_inv(long long a) {
return (power<long long>(a, mod - 2, mod)) % mod;
}
void factorial(long long n, vector<long long int> fact) {
fact.resize(n + 1, 1);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i <= n; ++i) {
fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;
}
}
int main() {
std::chrono::time_point<std::chrono::high_resolution_clock> start_timer,
end_timer;
start_timer = std::chrono::high_resolution_clock::now();
bool show_time = false;
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long n;
cin >> n;
if (n == 1) {
cout << ((1)) << "\n";
;
} else if (n == 2) {
cout << ((2)) << "\n";
;
} else if (n == 3) {
cout << ((6)) << "\n";
;
} else if (n % 2) {
cout << (((n * (n - 1) * (n - 2)))) << "\n";
;
} else
cout << (((max((((n - 3) * (n - 1) * (n - 2))) /
(gcd<long long>(n - 1, n - 2) *
gcd<long long>(n - 1, n - 3) *
gcd<long long>(n - 3, n - 2)),
(((n) * (n - 1) * (n - 3))) /
(gcd<long long>(n - 1, n - 3) *
gcd<long long>(n, n - 3) * gcd<long long>(n, n - 1))))))
<< "\n";
;
end_timer = std::chrono::high_resolution_clock::now();
long long elapsed_time =
std::chrono::duration_cast<std::chrono::milliseconds>(end_timer -
start_timer)
.count();
if (show_time) {
cout << "\nElapsed Time: " << elapsed_time << "ms\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
long long a, tmp, res = 1;
void swap(long long &a, long long &b) {
long long t = a;
a = b;
b = t;
}
long long gcd(long long a, long long b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
cin >> n;
tmp = (n - 200 >= 1) ? n - 200 : 1;
for (int i = tmp; i <= n; ++i) {
for (int j = tmp; j <= n; ++j) {
for (int k = tmp; k <= n; ++k) {
a = lcm(i, j);
a = lcm(a, k);
res = (res >= a) ? res : a;
}
}
}
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int n, lcm;
scanf("%lld", &n);
if (n == 2)
lcm = 2;
else if (n == 1)
lcm = 1;
else if (n % 2 == 1)
lcm = (n - 2) * (n - 1) * n;
else if (n % 3 == 0)
lcm = (n - 1) * (n - 2) * (n - 3);
else
lcm = n * (n - 1) * (n - 3);
printf("%lli", lcm);
return 0;
}
|
#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 * b / gcd(a, b); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, ans = 0;
cin >> n;
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)
ans = max(ans, lcm(lcm(i, j), k));
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long ans;
if (n <= 2)
ans = n;
else if (n % 2) {
ans = (n - 1) * (n - 2) * n;
} else if (n % 3) {
ans = n * (n - 1) * (n - 3);
} else
ans = (n - 1) * (n - 2) * (n - 3);
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, t, r, y;
cin >> n;
if (n <= 2) {
cout << n;
return 0;
}
if (n % 2 == 1)
t = n * (n - 1) * (n - 2);
else {
if (n % 3 == 0)
t = (n - 2) * (n - 1) * (n - 3);
else
t = n * (n - 1) * (n - 3);
}
cout << t;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long tpp = 9e18;
int tp = 1e9;
long long n, a;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
;
if (n == 1) {
cout << 1 << endl;
;
return 0;
;
}
if (n == 2) {
cout << 2 << endl;
;
return 0;
;
}
if (n == 3) {
cout << 6 << endl;
;
return 0;
;
}
if (n & 1) {
cout << n * (n - 1) * (n - 2) << endl;
;
return 0;
;
} else {
if (n % 3 == 0) {
cout << (n - 1) * (n - 2) * (n - 3) << endl;
;
return 0;
;
} else {
cout << n * (n - 1) * (n - 3) << endl;
;
return 0;
;
}
}
return 0;
;
}
|
#include <bits/stdc++.h>
int main() {
long long n;
scanf("%lld", &n);
if (n == 1)
puts("1");
else if (n == 2)
puts("2");
else if (n & 1)
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;
template <typename T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <typename T>
T sqr(T x) {
return x * x;
}
template <typename T>
T cube(T x) {
return x * x * x;
}
long long nok(long long a, long long b) {
long long g = gcd(a, b);
long long t = a / g * b;
return t;
}
long long NOK(long long a, long long b, long long c) {
return nok(nok(a, b), c);
}
int main() {
int n;
cin >> n;
if (n == 1) {
cout << 1 << endl;
return 0;
}
if (n == 2) {
cout << 2 << endl;
return 0;
}
long long res = -1;
for (int j = 0; j < 5 && n - j - 2 > 0; j++) {
long long s = (long long)(n - j) * (n - j - 1);
for (int i = n - j - 2; i >= 1; i--) {
long long t = nok(s, i);
res = max(res, t);
}
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n < 3) {
cout << n << endl;
} else if (n == 4) {
cout << 12 << endl;
} else if (n % 2)
cout << (n * (n - 1) * (n - 2)) << endl;
else {
if (!(n % 3))
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ucln(long long a, long long b) {
int t;
while (b != 0) {
a = a % b;
swap(a, b);
}
return a;
}
int main() {
long long n, res = 1, j;
cin >> n;
if (n < 3) {
cout << n;
return 0;
}
if (n % 6 == 0) {
n--;
n = n * (n - 1) * (n - 2);
cout << n;
return 0;
}
res = n * (n - 1);
j = n - 2;
while (ucln(j, res) != 1) j--;
res = res * j;
cout << res;
}
|
#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);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, ans = 0, pot;
long long a, b, c, e;
cin >> n;
if (n <= 2) {
cout << n;
return 0;
}
for (long long i = n - 1e3; i <= n; i++) {
a = i;
b = i - 1;
e = a * b;
for (long long j = max(1LL, i - 50); j <= i - 2; j++) {
c = j;
pot = (e * c) / gcd(e, c);
ans = max(ans, pot);
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
long long gcd(long long a, long long b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
long long n;
cin >> n;
switch (n) {
case 1:
cout << 1;
break;
case 2:
cout << 2;
break;
case 3:
cout << 6;
break;
case 4:
cout << 12;
break;
default:
if (n % 2)
cout << (n * (n - 1) * (n - 2));
else {
long long ans = 0;
for (long long i = max(n - 50, 1ll); i <= n; i++)
for (long long j = max(n - 50, 1ll); j <= n; j++)
for (long long k = max(n - 50, 1ll); k <= n; k++)
ans = max(ans, lcm(i, lcm(j, k)));
cout << ans;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long ans;
if (n == 1)
ans = 1;
else if (n == 2)
ans = 2;
else {
if (n % 2 != 0) {
ans = n * (n - 1) * (n - 2);
} else {
if (n % 3 == 0) {
ans = (n - 1) * (n - 2) * (n - 3);
} else {
ans = n * (n - 1) * (n - 3);
}
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const int inf = (1 << 31) - 1;
const int hinf = 1000000000;
const int mod = 1000000007;
long long gcd(long long a, long long b) {
if (a < b) swap(a, b);
return a % b == 0 ? b : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
long long n;
cin >> n;
if (n == 1) {
cout << 1 << endl;
return 0;
}
if (n == 2) {
cout << 2 << endl;
return 0;
}
if (n % 2 == 0 && n % 3 == 0) {
cout << lcm(n - 1, lcm(n - 2, n - 3)) << endl;
return 0;
}
long long ans = n * (n - 1);
long long ta = n * (n - 1);
for (long long i = n - 2; i > 0; i--) {
ta = n * (n - 1);
ta = lcm(ta, i);
ans = max(ans, ta);
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
while (b > 0) {
long long t = a;
a = b;
b = t % b;
}
return a;
}
int main() {
long long n;
cin >> n;
if (n >= 5) {
if (n % 2 == 1) {
cout << n * (n - 1) * (n - 2) << "\n";
} else {
cout << max((n - 1) * (n - 2) * (n - 3),
n * (n - 1) * (n - 3) / gcd(n, n - 3))
<< "\n";
}
} else if (n == 4) {
cout << "12\n";
} else if (n == 3) {
cout << "6\n";
} else if (n == 2) {
cout << "2\n";
} else if (n == 1) {
cout << "1\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long n(0);
scanf("%ld", &n);
if (n == 1) {
puts("1");
} else if (n == 2) {
puts("2");
} else if (n == 3) {
puts("6");
} else if (n > 3 && (n % 2 == 1)) {
cout << ((long long)n) * (n - 1) * (n - 2);
} else if (n > 3 && (n % 2 == 0) && (n % 3 == 0)) {
cout << ((long long)(n - 1)) * (n - 2) * (n - 3);
} else if (n > 3 && (n % 2 == 0) && (n % 3 != 0)) {
cout << ((long long)n) * (n - 1) * (n - 3);
} else {
puts("-1");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans;
while (~scanf("%lld", &n)) {
if (n < 3)
printf("%lld\n", n);
else {
if (n == 6) {
printf("60\n");
continue;
}
if (n & 1)
ans = n * (n - 1) * (n - 2);
else {
if (n % 3)
ans = n * (n - 1) * (n - 3);
else
ans = (n - 2) * (n - 1) * (n - 3);
}
printf("%lld\n", ans);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long i, j, k, l, t, n, ans;
while (cin >> n) {
if (n == 1)
ans = 1;
else if (n == 2)
ans = 2;
else if (n == 3)
ans = 6;
else if (n % 2 == 0) {
if (n % 3 == 0)
ans = (n - 1) * (n - 2) * (n - 3);
else
ans = n * (n - 1) * (n - 3);
} else
ans = n * (n - 1) * (n - 2);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long Inf = 1e9 + 7;
void boost_in_out() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cerr.tie(NULL);
}
long long n;
long long gcd(long long a, long long b) {
long long r;
while (a > 0) {
r = b % a;
b = a;
a = r;
}
return b;
}
signed main() {
boost_in_out();
cin >> n;
long long x = 0;
if (n <= 3) {
if (n == 3)
cout << 6;
else if (n == 2)
cout << 2;
else
cout << 1;
return 0;
}
for (long long i = max(1ll, n - 100); i <= n; ++i) {
for (long long j = max(1ll, n - 100); j <= n; ++j) {
if (i == j) continue;
for (long long k = max(1ll, n - 100); k <= n; ++k) {
if (i == k || j == k) continue;
long long fnok = i * j / gcd(i, j);
x = max(x, fnok * k / gcd(k, fnok));
}
}
}
cout << x;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n == 1)
cout << "1" << endl;
else if (n == 2)
cout << "2" << endl;
else if (n == 3)
cout << "6" << endl;
else if (n % 2 != 0)
cout << (n - 1) * (n - 2) * n << endl;
else {
if (n % 3 == 0)
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long int read() {
char c = getchar();
long long int num, sign = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') sign = -1;
for (num = 0; c >= '0' && c <= '9';) {
c -= '0';
num = num * 10 + c;
c = getchar();
}
return num * sign;
}
inline long long int pw(long long int b, long long int p) {
long long int ans = 1;
while (p > 0) {
if (p & 1) ans *= b;
p >>= 1;
b *= b;
}
return ans;
}
inline bool isPrime(long long int n) {
if (n == 1) return false;
if (n == 2) return true;
if (!(n % 2)) return false;
for (long long int i = 3; i <= sqrt(n); i += 2)
if (!(n % i)) return false;
return true;
}
inline long long int gcd(long long int a, long long int b) {
if (a == 0) return b;
return gcd(b % a, a);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n = read();
if (n == 1)
cout << 1 << endl;
else if (n == 2)
cout << 2 << endl;
else if (n == 3)
cout << 6 << endl;
else if (n == 4)
cout << 12 << endl;
else if (n % 2)
cout << n * (n - 1) * (n - 2) << endl;
else if (!(n % 2) && !(n % 3))
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n < 3) {
cout << n << endl;
} else if (n % 2 == 1) {
cout << n * (n - 1) * (n - 2) << endl;
} else {
if (n % 3 == 0)
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
}
return 0;
}
|
#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 %= b;
else
b %= a;
return a + b;
}
int main() {
long long n, res = 0, x, y, z, lcm, c = 50;
cin >> n;
for (x = n - c; x <= n; x++)
for (y = n - c; y <= n; y++)
for (z = n - c; z <= n; z++) {
if (x < 1 || y < 1 || z < 1) continue;
long long lcm = x / gcd(x, y) * y;
lcm = lcm / gcd(lcm, z) * z;
if (lcm > res) res = lcm;
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0LL)
return a;
else
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
long long n;
while (scanf("%I64d", &n) != EOF) {
long long a, res = 0LL;
int posa, posb, posc;
if (n - 100LL <= 0LL)
a = 1LL;
else
a = n - 100LL;
for (long long i = a; i <= n; i++) {
for (long long j = a; j <= n; j++) {
for (long long k = a; k <= n; k++) {
long long x = lcm(k, lcm(i, j));
res = max(res, x);
}
}
}
printf("%I64d\n", res);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
long long n;
cin >> n;
cout << (n > 2 ? (n - 2 * !(n % 6)) * (n - 1) * (n - 3 + n % 2) : n);
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
int main() {
long long int arr[100010] = {0};
long long int m, n, q, ans = 0;
scanf("%lld", &n);
if (n == 1) return 0 * printf("%s\n", "1");
if (n == 2) return 0 * printf("%s\n", "2");
if (n % 2 == 0) {
if (ans < n * (n - 1) * (n - 2) / 2) ans = n * (n - 1) * (n - 2) / 2;
if (ans < (n - 1) * (n - 2) * (n - 3)) ans = (n - 1) * (n - 2) * (n - 3);
if (n % 3 && ans < n * (n - 1) * (n - 3))
ans = n * (n - 1) * (n - 3);
else if (ans < n * (n - 1) * (n - 3) / 3)
ans = n * (n - 1) * (n - 3) / 3;
printf("%lld\n", ans);
} else
printf("%lld\n", n * (n - 1) * (n - 2));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long fun(long long x, long long y) {
long long tmp;
while (x % y != 0) {
tmp = x % y;
x = y;
y = tmp;
}
return y;
}
int main() {
long long n;
cin >> n;
long long k;
if (n == 1) {
k = 1;
} else if (n == 2) {
k = 2;
} else if (n % 2 != 0) {
k = (n) * (n - 1) * (n - 2);
} else if (n % 2 == 0) {
k = (n - 1) * (n - 2) * (n - 3);
long long i = 3;
while (i <= (5 * n - 6) / n) {
long long hcf;
hcf = fun(n, n - i);
if (hcf == 1) {
k = n * (n - 1) * (n - i);
break;
}
i++;
}
}
cout << k << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string en = "\n";
string sp = " ";
string t = "hello";
string Y = "YES\n";
string N = "NO\n";
int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1}, Row, Col;
int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
int kx[] = {-2, -2, 2, 2, -1, -1, 1, 1};
int ky[] = {-1, 1, -1, 1, -2, 2, -2, 2};
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
bool isprm(LL a) {
for (LL i = 2; i * i <= a; i++) {
if (a % i == 0) return false;
}
return true;
}
bool palin(string a) {
for (int i = 0; i < a.size(); i++) {
if (a.at(i) != a.at(a.size() - i - 1)) return 0;
}
return 1;
}
LL binpow(LL a, LL b) {
LL r = 1;
while (b > 0) {
if (b & 1) r = r * a;
a = a * a;
b >>= 1;
}
return r;
}
LL binpow(LL a, LL b, LL m) {
a %= m;
LL r = 1;
while (b > 0) {
if (b & 1) r = r * a % m;
a = a * a % m;
b >>= 1;
}
return r;
}
template <typename T>
inline T gcd(T a, T b) {
if (a < 0) return gcd(-a, b);
if (b < 0) return gcd(a, -b);
return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
if (a < 0) return lcm(-a, b);
if (b < 0) return lcm(a, -b);
return a * (b / gcd(a, b));
}
int main() {
LL i, j, k, n, m, l, s = 0, x, y, tc = 1, p, q, a, b, c = 0, d;
bool f = 0, ff = 0;
string st, sa, sb, sc;
char ch;
while (cin >> n) {
x = 0;
if (n == 1)
x = 1;
else if (n == 2)
x = 2;
else {
a = n, b = n - 1, c = n - 2;
x = a * b * c;
if (gcd(a, c) > 1) {
x = a * b * (c - 1);
x = x / gcd(a, (c - 1));
a--, b--, c--;
y = a * b * c;
y = y / gcd(a, c);
x = max(x, y);
}
}
cout << x << en;
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
if (a < 0) return gcd(-a, b);
if (b < 0) return gcd(a, -b);
return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
if (a < 0) return lcm(-a, b);
if (b < 0) return lcm(a, -b);
return a * (b / gcd(a, b));
}
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
T power(T N, T P) {
return (P == 0) ? 1 : N * power(N, P - 1);
}
long long toInt64(string s) {
long long r = 0;
istringstream sin(s);
sin >> r;
return r;
}
double LOG(long long N, long long B) { return (log10l(N)) / (log10l(B)); }
string itoa(long long a) {
if (a == 0) return "0";
string ret;
for (long long i = a; i > 0; i = i / 10) ret.push_back((i % 10) + 48);
reverse(ret.begin(), ret.end());
return ret;
}
vector<string> token(string a, string b) {
const char *q = a.c_str();
while (count(b.begin(), b.end(), *q)) q++;
vector<string> oot;
while (*q) {
const char *e = q;
while (*e && !count(b.begin(), b.end(), *e)) e++;
oot.push_back(string(q, e));
q = e;
while (count(b.begin(), b.end(), *q)) q++;
}
return oot;
}
template <class T>
inline T __cin() {
T ret;
cin >> ret;
return ret;
}
int isvowel(char s) {
s = tolower(s);
if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') return 1;
return 0;
}
int isupper(char s) {
if (s >= 'A' and s <= 'Z') return 1;
return 0;
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
int check(int N, int pos) { return (N & (1 << pos)); }
int toggle(int N, int pos) {
if (check(N, pos)) return N = reset(N, pos);
return N = Set(N, pos);
}
void pbit(int N) {
printf("(");
for (int i = 10; i >= 0; i--) {
bool x = check(N, i);
cout << x;
}
puts(")");
}
int main() {
int n = 9;
cin >> n;
long long ans = -1;
for (int i = max(n - 100, 1); i <= n; i++) {
for (int j = max(n - 100, 1); j <= n; j++) {
for (int k = max(n - 100, 1); k <= n; k++) {
long long lc = lcm((long long)i, lcm((long long)j, (long long)k));
ans = max(ans, lc);
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e5 + 5;
unsigned long long pw[67];
void pre() {
pw[0] = 1;
for (int i = 1; i < 64; i++) pw[i] = 2 * pw[i - 1];
}
int main() {
ios_base::sync_with_stdio(false);
pre();
long long n, ans = 1;
cin >> n;
if (n <= 2) {
cout << n << endl;
return 0;
}
if (n % 2 == 1) {
ans = n * (n - 1) * (n - 2);
} else {
if (n % 3 != 0) {
ans = max(n * (n - 1) * (n - 3), (n - 1) * (n - 2) * (n - 3));
} else
ans = (n - 1) * (n - 2) * (n - 3);
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
if (a < b) swap(a, b);
return (b == 0 ? a : GCD(b, a % b));
}
long long LCM(long long a, long long b, long long c) {
long long ans;
ans = a * b / GCD(a, b);
ans = ans * c / GCD(ans, c);
return ans;
}
int main() {
int i, j, k, n, idx, id;
long long maxi, number;
while (cin >> n) {
maxi = 0;
if (n == 1)
cout << 1 << endl;
else if (n == 2)
cout << 2 << endl;
else if (n == 3)
cout << 6 << endl;
else {
number = LCM(n, n - 1, n - 2);
maxi = max(number, maxi);
number = LCM(n, n - 1, n - 3);
maxi = max(number, maxi);
number = LCM(n - 1, n - 2, n - 3);
maxi = max(number, maxi);
number = LCM(n, n - 2, n - 3);
maxi = max(number, maxi);
cout << maxi << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
long long int tmp;
while (b) {
tmp = a % b;
a = b;
b = tmp;
}
return a;
}
int main() {
long long int n;
scanf("%I64d", &n);
if (n <= 2)
printf("%I64d\n", n);
else if (n & 1)
printf("%I64d\n", n * (n - 1) * (n - 2));
else if (n % 3 != 0)
printf("%I64d\n", n * (n - 1) * (n - 3));
else
printf("%I64d\n", (n - 1) * (n - 2) * (n - 3));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e18, M = 1e9 + 7;
void solve() {
long long int n;
cin >> n;
if (n <= 2) {
cout << n;
return;
}
if (n % 2)
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);
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans;
while (cin >> n) {
if (n == 1)
ans = 1;
else if (n == 2)
ans = 2;
else if (n == 3)
ans = 6;
else if (n % 2 == 0) {
if (n % 3 == 0)
ans = (n - 1) * (n - 2) * (n - 3);
else
ans = n * (n - 1) * (n - 3);
} else
ans = n * (n - 1) * (n - 2);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans;
while (scanf("%I64d", &n) != EOF) {
if (n == 1) {
printf("1\n");
continue;
}
if (n == 2) {
printf("2\n");
continue;
}
if (n % 6 == 0) {
ans = (n - 1) * (n - 2) * (n - 3);
printf("%I64d\n", ans);
continue;
}
if (n % 2 == 0) {
ans = n * (n - 1) * (n - 3);
} else {
ans = n * (n - 1) * (n - 2);
}
printf("%I64d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
cout << (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 int n;
cin >> n;
if (n == 1) {
std::cout << "1" << '\n';
return 0;
}
if (n == 2) {
std::cout << "2" << '\n';
return 0;
}
long long int ans1;
long long int ans2, ans3, ans4;
long long int max1;
if (n % 6 == 0) {
ans1 = n * (n - 1) * (n - 2);
ans1 /= 2;
ans2 = n * (n - 1) * (n - 3);
ans2 /= 3;
ans3 = n * (n - 1) * (n - 5);
ans4 = (n - 1) * (n - 2) * (n - 3);
max1 = max({ans1, ans2, ans3, ans4});
std::cout << max1 << '\n';
} else if (n % 2 == 0) {
ans1 = n * (n - 1) * (n - 2);
ans2 = n * (n - 1) * (n - 3);
ans1 /= 2;
if (ans1 > ans2) {
std::cout << ans1 << '\n';
} else {
std::cout << ans2 << '\n';
}
} else {
ans1 = n * (n - 1) * (n - 2);
std::cout << ans1 << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n == 1) {
cout << '1' << '\n';
return 0;
} else if (n == 2) {
cout << '2' << '\n';
return 0;
} else if (!(n % 2) && (n % 3)) {
unsigned long long ans1 = (n * (n - 1) * (n - 2)) / 2;
unsigned long long ans2 = (n - 1) * (n - 2) * (n - 3);
unsigned long long ans3 = (n * (n - 1) * (n - 3));
cout << max(max(ans1, ans2), ans3) << '\n';
} else if (!(n % 2)) {
unsigned long long ans1 = (n * (n - 1) * (n - 2)) / 2;
unsigned long long ans2 = (n - 1) * (n - 2) * (n - 3);
unsigned long long ans3 = (n * (n - 1) * (n - 3)) / 3;
cout << max(max(ans1, ans2), ans3) << '\n';
} else {
unsigned long long ans = n * (n - 1) * (n - 2);
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
int pow(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res *= x;
y >>= 1;
x *= x;
}
return res;
}
struct Compare {
constexpr bool operator()(
pair<long long, pair<long long, long long> > const &a,
pair<long long, pair<long long, long long> > const &b) const noexcept {
return a.first < b.first ||
(a.first == b.first && a.second.first > b.second.first);
}
};
void prefix_function(string second, long long arr[]) {
long long border = 0;
arr[0] = 0;
for (long long i = 1; i < second.size(); i++) {
while (border > 0 && second[i] != second[border]) border = arr[border - 1];
if (second[i] == second[border])
border++;
else
border = 0;
arr[i] = border;
}
}
long long mod = 998244353;
long long add(long long a, long long b) {
return (((a % mod) + (b % mod)) % mod);
}
long long mul(long long a, long long b) {
return (((a % mod) * (b % mod)) % mod);
}
long long binpow(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) res = mul(res, a);
a = mul(a, a);
b >>= 1;
}
return res;
}
long long subs(long long a, long long b) {
return (((a % mod) - (b % mod) + mod) % mod);
}
long long dv(long long a, long long b) {
long long inv = binpow(b, mod - 2);
return mul(a, inv);
}
long long dsu_arr[100000];
long long dsu_sz[100000];
void dsu(long long n) {
for (long long i = 0; i <= n; i++) {
dsu_arr[i] = i;
dsu_sz[i] = 1;
}
}
long long find(long long x) {
long long root = x;
while (root != dsu_arr[root]) {
root = dsu_arr[root];
}
while (x != dsu_arr[x]) {
dsu_arr[x] = root;
x = dsu_arr[x];
}
return root;
}
long long merge(long long x, long long y) {
long long root1 = find(x);
long long root2 = find(y);
if (root1 == root2) return 0ll;
if (dsu_sz[x] > dsu_sz[y]) {
dsu_arr[root2] = root1;
dsu_sz[root1] += dsu_sz[root2];
} else {
dsu_sz[root2] += dsu_sz[root1];
dsu_arr[root1] = root2;
}
return 1ll;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
if (n == 1) {
cout << 1 << endl;
return 0;
}
if (n == 2) {
cout << 2 << endl;
return 0;
}
if (n % 2 == 0) {
long long ans;
if (n % 3 != 0)
ans = n * (n - 1) * (n - 3);
else {
ans = (n - 1) * (n - 2) * (n - 3);
}
cout << ans << endl;
} else {
long long ans = n * (n - 1) * (n - 2);
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
long long gcd(long long a, long long b) {
long long r = a % b;
while (r) {
a = b;
b = r;
r = a % b;
}
return b;
}
int main() {
long long n;
long long max;
while (scanf("%I64d", &n) != EOF) {
if (n == 1)
max = 1;
else if (n == 2)
max = 2;
else {
if (n % 2)
max = n * (n - 1) * (n - 2);
else {
if (n % 3)
max = n * (n - 1) * (n - 3);
else
max = (n - 1) * (n - 2) * (n - 3);
}
}
printf("%I64d\n", max);
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int n, lcm;
scanf("%lld", &n);
if (n == 1) {
lcm = 1;
} else if (n == 2) {
lcm = 2;
} else if (n % 6 == 0) {
lcm = (n - 1) * (n - 2) * (n - 3);
} else if (n % 2 == 0) {
lcm = (n) * (n - 1) * (n - 3);
} else {
lcm = (n) * (n - 1) * (n - 2);
}
printf("%lld", lcm);
}
|
#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) { return ((b == 0) ? a : GCD(b, a % b)); }
int main() {
long long n;
cin >> n;
if (n == 1 || n == 2) return cout << n, 0;
if (n % 6 == 0) return cout << (n - 1) * (n - 2) * (n - 3), 0;
if (n % 2) return cout << n * (n - 1) * (n - 2), 0;
cout << n * (n - 1) * (n - 3);
}
|
#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long slove(long long a, long long b) {
long long c = gcd(a, b);
return a * b / c;
}
int main() {
long long int n;
while (~scanf("%I64d", &n)) {
if (n == 1) {
cout << 1 << endl;
continue;
}
if (n == 2) {
cout << 2 << endl;
continue;
}
if (n == 3) {
cout << 6 << endl;
continue;
}
if (n == 4) {
cout << 12 << endl;
continue;
}
if (n == 5) {
cout << 60 << endl;
continue;
} else {
if (n % 2) {
cout << n * (n - 1) * (n - 2) << endl;
} else {
long long ans = (n - 1) * (n - 2) * (n - 3);
long long res = (n - 1) * n;
for (long long i = n - 3; i * res > ans; i -= 2) {
if (slove(res, i) > ans) {
ans = slove(res, i);
break;
}
}
cout << ans << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n;
cin >> n;
long long ans;
if (n == 1)
ans = 1;
else if (n == 2)
ans = 2;
else if (n & 1)
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 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
bool prime[N + 10];
int n;
void gen() {
prime[1] = true;
for (int i = 2; i < N; i++) {
int j = i * i;
while (j <= N) {
prime[j] = true;
j += i;
}
}
}
int main() {
long long n;
cin >> n;
if (n == 1)
cout << 1;
else if (n == 2)
cout << 2;
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);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e9) + 7;
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 * b) / gcd(a, b)); }
void solve() {
long long n, ans;
cin >> n;
if (n <= 4) {
ans = max(1LL, n * (n - 1));
} else {
ans = max({lcm(n, lcm(n - 1, n - 2)), lcm(n - 1, lcm(n - 2, n - 3)),
lcm(n, lcm(n - 1, n - 3))});
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long int n;
cin >> n;
if (n == 1) cout << 1 << endl;
if (n == 2) cout << 2 << endl;
if (n >= 3) {
if (n % 2 == 1) cout << n * (n - 1) * (n - 2) << endl;
if (n % 2 == 0 && n % 3 != 0) cout << (n * (n - 1) * (n - 3)) << endl;
if (n % 2 == 0 && n % 3 == 0) cout << (n - 2) * (n - 3) * (n - 1) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long int n, total;
scanf("%lld", &n);
if (n == 1)
total = 1;
else if (n == 2)
total = 2;
else if (n % 2 != 0) {
total = n * (n - 1) * (n - 2);
} else if (n % 2 == 0) {
if (n % 6 == 0) {
total = (n - 1) * (n - 2) * (n - 3);
} else {
total = n * (n - 1) * (n - 3);
}
}
printf("%lld\n", total);
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 % 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);
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
unsigned long long gcd(unsigned long long a, unsigned long long b) {
unsigned long long r;
if (a < b) {
a ^= b;
b ^= a;
a ^= b;
}
r = a % b;
if (r == 0)
return b;
else
return gcd(b, r);
}
int main() {
unsigned long long n;
unsigned long long max;
unsigned long long i;
while (scanf("%I64u", &n) != EOF) {
if (n % 2 == 1) {
if (n == 1)
printf("1\n");
else
printf("%I64u\n", n * (n - 1) * (n - 2));
} else {
if (n == 2)
printf("2\n");
else {
for (i = n - 2; gcd(i, n) != 1 || gcd(i, n - 1) != 1; i--)
;
max = (n * (n - 1) * i);
if (max < ((n - 1) * (n - 2) * (n - 3)))
max = ((n - 1) * (n - 2) * (n - 3));
printf("%I64u\n", max);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:256000000")
using namespace std;
const int N = 1000500, M = 200500, INF = 1000 * 1000 * 1000 + 7;
const long double eps = 1e-9;
bool a[N];
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcd(long long a, long long b) { return a / gcd(a, b) * b; }
bool solve() {
int n;
if (scanf("%d", &n) != 1) return false;
long long ans = 1;
int to = min(100, n);
for (int i = 0; i < to; i++) {
for (int j = 0; j < to; j++) {
for (int k = 0; k < to; k++) {
ans = max(ans, lcd(n - i, lcd(n - j, n - k)));
}
}
}
cout << ans << endl;
return true;
}
int main() {
a[0] = true;
a[1] = true;
for (int i = 0; i < N; i++) {
if (a[i]) continue;
for (int j = i + i; j < N; j += i) a[j] = true;
}
while (solve())
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
inline long long int gcd(long long int ga, long long int gb) {
if (!gb) return ga;
return gcd(gb, ga % gb);
}
inline long long int lcm(long long int a, long long int b, long long int c) {
long long int ans = a * b / gcd(a, b);
return ans * c / gcd(ans, c);
}
int main() {
long long int n;
scanf("%lld", &n);
if (n == 1)
printf("1");
else if (n == 2)
printf("2");
else if (n & 1)
printf("%lld", n * (n - 1) * (n - 2));
else {
long long int ans(1);
for (int i = 1; i <= n; ++i) ans = max(ans, lcm(n, n - 1, i));
printf("%lld", max(ans, max((n - 1) * (n - 2) * (n - 3),
n * (n - 1) * (n - 2) / 2)));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long n;
cin >> n;
if (n == 1)
cout << 1 << '\n';
else if (n == 2)
cout << 2 << '\n';
else {
if (n % 2 == 0) {
if (n % 3 == 0) {
cout << (n - 1) * (n - 2) * (n - 3) << '\n';
} else
cout << n * (n - 1) * (n - 3) << '\n';
} else
cout << n * (n - 1) * (n - 2) << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long n;
cin >> n;
unsigned long long answer = 1;
if (n < 3) {
answer = n;
} else if (n % 2 != 0) {
answer = n * (n - 1) * (n - 2);
} else {
answer = n * (n - 1) * (n - 3);
if ((n) % 3 == 0) {
answer = (n - 1) * (n - 2) * (n - 3);
}
}
cout << answer;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int big, long long int small) {
if (big % small == 0) return small;
gcd(small, big % small);
}
int main() {
long int t;
t = 1;
while (t--) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n;
cin >> n;
long long int x, y, z, i, j;
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 {
for (i = n - 2; i >= 1; i--) {
x = gcd(n, i);
y = gcd(n - 1, i);
if (x == 1 && y == 1) {
if (n * (n - 1) * i >= (n - 1) * (n - 2) * (n - 3))
cout << n * (n - 1) * i << endl;
else
cout << (n - 1) * (n - 2) * (n - 3) << endl;
goto xx;
}
}
}
xx:;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool comp(char& a, char& b);
long long gcd(long long a, long long b);
int factorial(int n);
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int64_t 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) {
int64_t ans = n * (n - 1) * (n - 2);
cout << ans;
} else {
int64_t k1 = n - 1, k2 = n - 3;
if (gcd(n, k2) > 1) {
n--;
k1--;
}
int64_t ans = n * k1 * k2;
cout << ans << endl;
}
return 0;
}
int factorial(int n) {
int result = 1;
for (int i = 2; i <= n; ++i) {
result *= i;
}
return result;
}
bool comp(char& a, char& b) { return a > b; }
long long gcd(long long a, long long b) {
long long nod = 1L;
long long tmp;
if (a == 0L) return b;
if (b == 0L) return a;
if (a == b) return a;
if (a == 1L || b == 1L) return 1L;
while (a != 0 && b != 0) {
if (((a & 1L) | (b & 1L)) == 0L) {
nod <<= 1L;
a >>= 1L;
b >>= 1L;
continue;
}
if (((a & 1L) == 0L) && (b & 1L)) {
a >>= 1L;
continue;
}
if ((a & 1L) && ((b & 1L) == 0L)) {
b >>= 1L;
continue;
}
if (a > b) {
tmp = a;
a = b;
b = tmp;
}
tmp = a;
a = (b - a) >> 1L;
b = tmp;
}
if (a == 0)
return nod * b;
else
return nod * a;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[1000005];
long long a1[9];
long long a2[9];
char kalimat[100005];
int main() {
long long sisa1, sisa2, a, b, temp, kelompok, jum, i;
scanf("%lld", &a);
getchar();
if (a <= 4) {
if (a == 4) {
cout << "12" << endl;
} else if (a == 3) {
cout << "6" << endl;
} else if (a == 2) {
cout << "2" << endl;
} else if (a == 1) {
cout << "1" << 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>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int nomalDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leapDay[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int ARRSIZE = 100100;
const int STRSIZE = 100100;
const int TEMPSIZE = 1010;
const int GRIDSIZE = 510;
const int MAXINF = (2 << 26);
const int MININF = (~(2 << 26));
const double PI = 3.1415926535897932384626433832795;
struct node {
int x, y;
};
inline bool upcmp(int a, int b) { return a < b; }
inline bool downcmp(int a, int b) { return a > b; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long i, long long j) { return (i * j) / gcd(i, j); }
long long lcm3(long i, long j, long k) { return lcm(lcm(i, j), k); }
int main() {
long long i, j, k, n, res = 1;
cin >> n;
if (n == 1) {
res = 1;
} else if (n == 2) {
res = 2;
} else if (n == 3) {
res = 6;
} else if (n == 4) {
res = 12;
} else if (n == 5) {
res = 60;
} else
for (i = n - 5; i <= n; i++)
for (j = n - 5; j <= n; j++)
for (k = n - 5; k <= n; k++) res = max(res, lcm3(i, j, k));
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int n;
int main() {
long long n;
scanf("%lld", &n);
if (n == 1)
printf("1");
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() {
long long int n;
cin >> n;
if (n <= 2) {
cout << n << endl;
} else if (n == 3)
cout << 6 << endl;
else {
if (n % 2 == 1)
cout << n * (n - 1) * (n - 2) << endl;
else {
if (n % 3 == 0)
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long ans;
int n;
long long gcd(long long a, long long b) {
while (a && b) {
if (a > b) {
a %= b;
} else {
b %= a;
}
}
return a + b;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
scanf("%d", &n);
ans = 0;
for (int i = n; i >= max(n - 50, 1); i--) {
for (int ii = n; ii >= max(n - 50, 1); ii--) {
for (int iii = n; iii >= max(n - 50, 1); iii--) {
ans = max(ans, lcm(iii, lcm(i, ii)));
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
cin >> n;
long long ans = 0;
if (n == 1 || n == 2) {
cout << n << endl;
return 0;
}
if (n % 2) {
cout << n * (n - 1) * (n - 2) << endl;
return 0;
}
ans = max(ans, n * (n - 1) * (n - 2) / 2);
ans = max(ans, (n - 1) * (n - 2) * (n - 3));
ans = max(ans, n * (n - 1) * (n - 3) / gcd(n, n - 3));
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin >> n;
if (n >= 3) {
if (n % 2)
cout << n * (n - 1) * (n - 2) << '\n';
else if (n % 3)
cout << (n) * (n - 1) * (n - 3) << "\n";
else
cout << (n - 1) * (n - 2) * (n - 3) << "\n";
} else if (n == 2)
cout << 2 << '\n';
else
cout << 1 << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
scanf("%lld", &n);
if (n == 1)
cout << 1 << endl;
else if (n == 2)
cout << 2 << endl;
else if (n % 2 != 0)
cout << n * (n - 1) * (n - 2) << endl;
else if (n % 3 == 0)
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (!b) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
long long n;
cin >> n;
long long mx = 1;
for (int i = 0; i < 10; ++i)
for (int j = i + 1; j < 10; ++j)
for (int k = j + 1; k < 10; ++k)
if (n - i > 0 && n - j > 0 && n - k > 0)
mx = max(mx, lcm(n - i, lcm(n - j, n - k)));
cout << max(mx, n) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int n) {
long long int ans;
if (n < 3)
ans = n;
else if (n == 6)
ans = 60;
else if (n % 2)
ans = n * (n - 1) * (n - 2);
else {
ans = n * (n - 1) * (n - 3);
if (n % 3 == 0 && (n - 3) % 3 == 0) ans /= 3;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int n;
cin >> n;
cout << max(solve(n), solve(n - 1));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if (n == 1) {
cout << 1;
} else if (n == 2) {
cout << 2;
} else if (n == 3) {
cout << 6;
} else if (n % 2 == 0) {
long long A = n * (n - 1) * (n - 2) / 2;
long long B = n * (n - 1) * (n - 3);
long long C = (n - 1) * (n - 2) * (n - 3);
if (n % 3 == 0) B /= 3;
cout << max(A, max(B, C));
} else {
cout << n * (n - 1) * (n - 2);
}
return 0;
}
|
#include <bits/stdc++.h>
long long la, la1;
int main() {
long long n;
scanf("%I64d", &n);
if (n == 1)
la = 1;
else if (n == 2)
la = 2;
else {
if (n % 2 == 1) {
la = n * (n - 1) * (n - 2);
} else {
la = (n - 1) * (n - 2) * (n - 3);
la1 = n * (n - 1) * (n - 2);
la1 /= 2;
if (la1 > la) la = la1;
la1 = n * (n - 1) * (n - 3);
if (n % 3 == 0) la1 /= 3;
if (la1 > la) la = la1;
la1 = n * (n - 1) * (n - 5);
if (n % 5 == 0) la1 /= 5;
if (la1 > la) la = la1;
}
}
printf("%I64d", la);
return 0;
}
|
#include <bits/stdc++.h>
long long int Max(long long int a, long long int b) { return a > b ? a : b; }
long long int gcd(long long int a, long long int b) {
if (b == 0)
return a;
else if (a == 0)
return b;
else if (a < b)
return gcd(a, b % a);
else
return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
return a * b / gcd(a, b);
}
int main() {
int n;
while (~scanf("%d", &n)) {
if (n == 1 || n == 2)
printf("%d\n", n);
else {
long long int tmp = lcm(n, n - 1);
long long int max = 0;
for (int i = 1; i <= n; i++) {
max = Max(max, lcm(tmp, i));
}
tmp = lcm(n - 2, n - 1);
for (int i = 1; i <= n - 2; i++) {
max = Max(max, lcm(tmp, i));
}
printf("%I64d\n", max);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T b, T p, T m) {
T ret;
if (p == 0) return 1;
if (p & 1) {
ret = (bigmod(b, p / 2, m) % m);
return ((b % m) * ret * ret) % m;
} else {
ret = (bigmod(b, p / 2, m) % m);
return (ret * ret) % m;
}
}
template <class T>
inline T _sqrt(T a) {
return (T)sqrt((double)a);
}
template <class T, class X>
inline T _pow(T a, X b) {
T res = 1;
for (int i = 1; i <= b; i++) res *= a;
return res;
}
int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int dx6[] = {0, 0, 1, -1, 0, 0};
int dy6[] = {1, -1, 0, 0, 0, 0};
int dz6[] = {0, 0, 0, 0, 1, -1};
int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2};
int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1};
int tc = 1;
const long long int mx = 1000000;
int main() {
long long sum, n;
while (cin >> n) {
if (n % 2)
sum = n * (n - 1) * (n - 2);
else
sum = n * (n - 1) * (n - 3);
if (n == 1)
sum = 1;
else if (n == 2)
sum = 2;
else if (n == 3)
sum = 6;
else if (n % 6 == 0)
sum = (n - 1) * (n - 2) * (n - 3);
cout << sum << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ucln(long long a, long long b) {
if (b == 0)
return a;
else
return ucln(b, a % b);
}
long long bcnn(long long a, long long b) { return (a * b) / ucln(a, b); }
long long thuchien(long long n) {
long long a, b;
for (long long i = n; i >= 1; i--)
if (ucln(n, i) == 1) {
a = i;
break;
}
for (long long i = a; i >= 1; i--)
if (ucln(n, i) == 1 && ucln(a, i) == 1) {
b = i;
break;
}
return n * a * b;
}
int main() {
long long n, res = 0;
cin >> n;
for (long long i = n; i >= n / 2; i--) res = max(res, thuchien(i));
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int OO = (int)1e9;
long long n, res;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
int main() {
cin.sync_with_stdio(false);
cin >> n;
if (n <= 2) return cout << n, 0;
if (n & 1) {
printf("%lld", n * (n - 1) * (n - 2));
} else {
for (int i = max(1ll, n - 100); i <= n; i++) {
for (int j = max(1ll, n - 100); j <= n; j++) {
for (int x = max(1ll, n - 100); x <= n; x++) {
long long ans = 1ll * i * j / gcd(i, j);
ans = ans * x / gcd(ans, x);
res = max(ans, res);
}
}
}
printf("%lld", res);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
long long n, ans = 0;
cin >> n;
for (long long i = max(1LL, n - 300); i <= n; ++i)
for (long long j = i; j <= n; ++j)
for (long long k = j; k <= n; ++k) {
long long lcm = i / gcd(i, j) * j;
lcm = lcm / gcd(lcm, k) * k;
if (lcm > ans) ans = lcm;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long int n;
cin >> n;
if (n == 1) {
cout << "1";
return 0;
}
if (n == 2) {
cout << "2";
return 0;
}
if (n == 3) {
cout << "6";
return 0;
}
if (n == 4) {
cout << "12";
return 0;
}
unsigned long long int num = n * (n - 1) * (n - 2);
unsigned long long int k = (n) * (n - 1) * (n - 3);
if (n % 2 == 0) {
if (n % 3 == 0) {
cout << (n - 1) * (n - 2) * (n - 3);
return 0;
} else {
cout << k;
return 0;
}
} else
cout << num;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
ios::sync_with_stdio(false);
cin >> n;
if (n == 1)
cout << n << endl;
else if (n == 2)
cout << n << endl;
else if (n == 3)
cout << 6 << endl;
else if (n == 4)
cout << 12 << endl;
else {
if (n & 1)
cout << 1ll * n * (n - 1) * (n - 2) << endl;
else if (n % 3 == 0)
cout << 1ll * (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << 1ll * n * (n - 1) * (n - 3) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
int x, y;
bool operator<(const point &a) const { return x > a.x; }
};
priority_queue<int> que;
long long n, s1, s2;
int a[20] = {0, 1, 2, 6, 12, 60, 60};
long long b[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int main() {
while (~scanf("%d", &n)) {
if (n < 7) {
printf("%d\n", a[n]);
continue;
}
s1 = n * (n - 1) * (n - 2);
if (n % 2 == 0) {
s1 = s1 / 2;
for (int i = 0; i < 10; i++) {
if (n % b[i] != 0) {
s2 = n * (n - 1) * (n - b[i]);
break;
}
}
if (s2 > s1) s1 = s2;
s2 = (n - 1) * (n - 2) * (n - 3);
if (s2 > s1) s1 = s2;
}
printf("%lld\n", s1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void alert(const T& t) {
cout << t;
exit(0);
}
template <typename T>
inline void alert(vector<T>& t, char delim = ' ') {
for (T const& ti : t) cout << ti << delim;
exit(0);
}
const long long MAX64 = 1 + 1e+18;
const int MAX = 1 + 1e+9;
const double PI = 3.1415926536;
const long long CEL = 26;
long long MID(long long l, long long r) { return (l + r) / 2; }
long long LSON(long long u) { return u * 2; }
long long RSON(long long u) { return u * 2 + 1; }
struct Point {
Point() : x(0), y(0){};
Point(double X, double Y) : x(X), y(Y){};
double x;
double y;
};
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 * b) / GCD(a, b); }
int main() {
{}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
long long n;
cin >> n;
if (n < 3) alert(n);
if (n == 4) alert(12);
long long answer;
if (n % 2 == 1)
answer = n * (n - 1) * (n - 2);
else {
if (n % 3 == 0)
answer = (n - 1) * (n - 2) * (n - 3);
else
answer = n * (n - 1) * (n - 3);
}
alert(answer);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long m, flag, inf, v;
long long t, c = 0, next;
int main() {
long long m;
scanf("%lld", &m);
if (m < 3)
printf("%lld\n", m);
else {
if (m % 2 != 0)
printf("%lld", m * (m - 1) * (m - 2));
else {
if (m % 3 == 0)
printf("%lld\n", (m - 1) * (m - 2) * (m - 3));
else {
printf("%lld\n", m * (m - 1) * (m - 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 %= b;
else
b %= a;
return a + b;
}
int main(int argc, char* argv[]) {
int n;
cin >> n;
if (n < 3)
cout << n << endl;
else {
long long res = (long long)n;
for (int a = n; ((long long)a) * ((long long)a) * ((long long)a) > res; a--)
for (int b = a; ((long long)a) * ((long long)b) * ((long long)b) > res;
b--) {
long long lcm_a_b = ((long long)a) * ((long long)b) / gcd(a, b);
for (int c = b; lcm_a_b * ((long long)c) > res; c--) {
long long lcm_a_b_c = lcm_a_b * ((long long)c) / gcd(lcm_a_b, c);
res = max(res, lcm_a_b_c);
}
};
cout << res << endl;
}
return 0;
}
|
#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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
n = IN();
if (n <= 2) return printf("%d\n", n), 0;
if (n == 3) return puts("6"), 0;
if (n & 1) return OUT(1ll * n * (n - 1) * (n - 2)), 0;
long long Ans = 1ll * (n - 1) * (n - 2) * (n - 3);
for (int i = max(1, n - 50); i <= n; i++)
for (int j = max(1, n - 50); j <= n; j++)
for (int k = max(1, n - 50); k <= n; k++) {
long long now = 1ll * i * j / gcd(i, j);
now = 1ll * now * k / gcd(now, k);
Ans = max(Ans, now);
}
OUT(Ans);
}
|
#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 lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
if (n < 3) {
cout << n;
} else {
if (n % 2)
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 f(long long n) {
if (n < 3) return n;
if (n % 2 == 1) return n * (n - 1) * (n - 2);
long long r = (n * (n - 1) * (n - 2)) / 2;
long long t = 0;
if (n % 3 != 0) {
t = n * (n - 1) * (n - 3);
if (t > r) r = t;
}
--n;
t = n * (n - 1) * (n - 2);
if (r < t) r = t;
return r;
}
int main() {
long long a, b, c, n;
cin >> n;
cout << f(n) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, num;
cin >> n;
if (n <= 2)
cout << n;
else {
if (n % 6 == 0) {
num = ((n - 1) * (n - 2) * (n - 3));
cout << num;
} else if (n % 2 == 0) {
num = ((n - 1) * (n) * (n - 3));
cout << num;
} else {
num = n * (n - 1) * (n - 2);
cout << num;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long n;
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 * (b / gcd(a, b)); }
int main() {
cin >> n;
if (n == 1) {
cout << 1;
return 0;
}
if (n == 2) {
cout << 2;
return 0;
}
if (n == 3) {
cout << 6;
return 0;
}
cout << max(lcm(lcm(n, n - 1), n - 2),
max(lcm(lcm(n - 1, n - 2), n - 3), lcm(lcm(n - 1, n), n - 3)));
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
long long n;
while (cin >> n) {
long long ans = 0;
long long temp = max((long long)0, n - 100);
long long tempa, tempb;
for (long long i = n; i > temp; i--)
for (long long j = n; j > temp; j--)
for (long long k = n; k > temp; k--) {
tempa = gcd(i, j);
tempb = i * j / tempa;
tempa = gcd(tempb, k);
tempb = tempb * k / tempa;
ans = max(ans, tempb);
}
cout << ans << endl;
}
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 << endl;
else if (n == 2)
cout << 2 << endl;
else if (n == 3)
cout << 6 << endl;
else if (n == 4)
cout << 12 << endl;
else if (n % 2)
cout << n * (n - 1) * (n - 2) << endl;
else if (!(n % 2) && !(n % 3))
cout << (n - 1) * (n - 2) * (n - 3) << endl;
else
cout << n * (n - 1) * (n - 3) << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
int main() {
int n;
long long ans;
scanf("%d", &n);
if (n < 3) {
ans = n;
} else if (n % 2 == 1) {
ans = (long long)n * (n - 1) * (n - 2);
} else if (n % 2 == 0 and n % 3 != 0) {
ans = (long long)n * (n - 1) * (n - 3);
} else {
ans = (long long)(n - 1) * (n - 2) * (n - 3);
}
printf("%lld\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
int main(void) {
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 && n % 3 == 0)
printf("%lld\n", (n - 1) * (n - 2) * (n - 3));
else if (n % 2 == 1)
printf("%lld\n", n * (n - 1) * (n - 2));
else
printf("%lld\n", n * (n - 1) * (n - 3));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, l;
cin >> n;
if (n < 3)
cout << n;
else if (n % 2 != 0)
cout << n * (n - 1) * (n - 2);
else if (n % 6 == 0)
cout << (n - 1) * (n - 2) * (n - 3);
else
cout << n * (n - 1) * (n - 3);
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e5 + 10, mod = 1e9 + 9, base = 41, INF = 1e9 + 10, sq = 502;
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; }
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
long long t;
cin >> t;
if (t <= 2)
cout << t << endl;
else if (t % 2 == 0)
cout << max((t - 1) * lcm(t, t - 3),
max((t - 1) * lcm(t, t - 2), (t - 1) * (t - 2) * (t - 3)))
<< endl;
else
cout << (t * (t - 1) * (t - 2)) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n;
cin >> n;
if (n <= 2)
cout << n;
else if (n % 2 != 0)
cout << n * (n - 1) * (n - 2);
else {
if (n % 6 == 0)
cout << (n - 1) * (n - 2) * (n - 3);
else
cout << n * (n - 1) * (n - 3);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, result;
cin >> n;
if (n < 3) {
result = n;
} else if (n % 2 == 0) {
if (n % 3 == 0) {
result = (n - 1) * (n - 2) * (n - 3);
} else {
result = n * (n - 1) * (n - 3);
}
} else {
result = n * (n - 1) * (n - 2);
}
cout << result << endl;
}
|
#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 == 1)
cout << "1";
else if (n == 2)
cout << "2";
else if (n <= 3)
cout << "6";
else if (n == 6)
cout << "60";
else if (n % 3 == 0 && n % 2 == 0)
cout << (n - 1) * (n - 2) * (n - 3);
else {
if (n % 2 != 0)
cout << n * (n - 1) * (n - 2);
else
cout << n * (n - 1) * (n - 3);
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.