Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll fun(int n, ll k)
{
ll max_v = k / n;
ll optimal_v = k / (2 * n);
ll ans = 0;
for (ll v : {optimal_v, optimal_v - 1, optimal_v + 1})
{
if (v < 0)
continue;
ll Y = v;
ll X = k - n * v;
if (X >= 0)
{
ans = max(ans, X * Y);
}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--)
{
int n;
ll k;
cin >> n >> k;
cout << fun(n, k) << '\n';
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1092 Bitwise AND
- Contest
- Brain Booster #5
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-09-05 17:19:38
- Judged At
- 2024-11-11 02:58:23
- Judged By
- Score
- 100
- Total Time
- 30ms
- Peak Memory
- 2.125 MiB