結果
問題 | No.2420 Simple Problem |
ユーザー |
|
提出日時 | 2023-08-12 16:19:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 1,719 ms |
コンパイル使用メモリ | 166,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-20 05:28:30 |
合計ジャッジ時間 | 8,123 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;template<typename T> T MUL(T a, T b){T res;return __builtin_mul_overflow(a, b, &res)? std::numeric_limits<T>::max() : res;}int main(){ios::sync_with_stdio(false);cin.tie(0);int T;cin >> T;while(T--){ll a, b;cin >> a >> b;ll ng = 0, ok = 1 << 16, mid;while(ng + 1 < ok){mid = (ng + ok) / 2;ll r = max(0ll, mid * mid - a - b);if(4 * a * b < MUL(r, r)) ok = mid;else ng = mid;}cout << ok << '\n';}}