結果

問題 No.2420 Simple Problem
ユーザー xuelei
提出日時 2023-08-12 14:17:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 165,992 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 18:25:51
合計ジャッジ時間 7,386 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--)
#define all(v) v.begin(), v.end()

typedef long long ll;
template <class T> using V = vector<T>;
template <class T> using VV = vector<V<T>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    constexpr char endl = '\n';

    int n;
    cin >> n;
    while (n--) {
        ll a,b;
        cin >> a >> b;
        ll x = sqrt(a) + sqrt(b);
        x--;
        while (1) {
            ll num1 = 4LL * a * b;
            ll num2 = x * x - a - b;
            if (num2 * num2 > num1) {
                cout << x << endl;
                break;
            }
            x++;
        }
    }
    return 0;
}
0