結果

問題 No.2420 Simple Problem
ユーザー srjywrdnprkt
提出日時 2023-08-12 14:14:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 2,663 ms
コンパイル使用メモリ 192,236 KB
最終ジャッジ日時 2025-02-16 04:27:00
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

bool f(ll X, ll A, ll B){
    if (X*X-A-B <= 0) return 0;
    if (X*X-A-B > 3e9) return 1;
    return A*B*4 < (X*X-A-B) * (X*X-A-B);
}

void solve(){
    ll A, B;
    cin >> A >> B;
    ll l=0, r=1e9, c;
    while(r-l>1){
        c = (l+r)/2;
        if (f(c, A, B)) r=c;
        else l=c;
    }

    cout << r << endl;
}

int main(){

    int N;
    cin >> N;
    while(N){
        N--;
        solve();
    }

    return 0;
}
0