結果
| 問題 | No.2420 Simple Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-03 16:46:42 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 676 bytes |
| 記録 | |
| コンパイル時間 | 2,197 ms |
| コンパイル使用メモリ | 334,540 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-03 16:46:50 |
| 合計ジャッジ時間 | 7,151 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using U = unsigned __int128;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
while (n--) {
ll aa, bb;
cin >> aa >> bb;
U a = aa, b = bb;
U l = 2, r = 1000000;
auto ok = [&](U x) -> bool {
U xx = x * x;
if (xx <= a + b) return false;
U t = xx - a - b;
return t * t > 4 * a * b;
};
while (r - l > 1) {
U x = (l + r) / 2;
if (ok(x)) r = x;
else l = x;
}
cout << (ll)r << '\n';
}
return 0;
}