Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "PAIRLCM"
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 1e5 + 5;
- int n;
- void Read()
- {
- cin >> n;
- }
- bool IsOdd(int v)
- {
- return v & 1;
- }
- ll lcm(int x, int y)
- {
- return 1ll * x * y / __gcd(x, y);
- }
- void Solve()
- {
- if (IsOdd(n))
- cout << 1ll * (n / 2) * (n / 2 + 1);
- else
- {
- ll v = n / 2;
- if (n / 2 > 1)
- v = max(v, lcm(n / 2 - 1, n / 2 + 1));
- if (n / 2 > 2)
- v = max(v, lcm(n / 2 - 2, n / 2 + 2));
- cout << v;
- }
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Add Comment
Please, Sign In to add comment