Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
int n, k; cin >> n >> k;
auto f = [&] (int m) {
return (k - m * n) * m;
};
int l = 0, r = k / n + 1;
while (r - l > 1) {
int m = l + (r - l) / 2;
if (f(m) < f(m + 1)) l = m;
else r = m;
}
cout << (k - r * n) * r << '\n';
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(nullptr);
i64 T; cin >> T;
while(T--) solve();
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1092 Bitwise AND
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-03 17:59:18
- Judged At
- 2024-11-11 02:45:16
- Judged By
- Score
- 10
- Total Time
- 2ms
- Peak Memory
- 540.0 KiB