結果

問題 No.2420 Simple Problem
ユーザー HIcoderHIcoder
提出日時 2023-08-20 23:34:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 1,246 ms
コンパイル使用メモリ 102,016 KB
実行使用メモリ 5,708 KB
最終ジャッジ日時 2024-05-08 05:21:57
合計ジャッジ時間 24,707 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 266 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 97 ms
5,376 KB
testcase_04 AC 506 ms
5,452 KB
testcase_05 AC 322 ms
5,376 KB
testcase_06 AC 641 ms
5,708 KB
testcase_07 AC 634 ms
5,452 KB
testcase_08 AC 628 ms
5,448 KB
testcase_09 AC 644 ms
5,456 KB
testcase_10 AC 634 ms
5,452 KB
testcase_11 AC 638 ms
5,452 KB
testcase_12 AC 632 ms
5,448 KB
testcase_13 AC 637 ms
5,584 KB
testcase_14 AC 629 ms
5,376 KB
testcase_15 AC 628 ms
5,452 KB
testcase_16 AC 651 ms
5,544 KB
testcase_17 AC 626 ms
5,448 KB
testcase_18 AC 631 ms
5,452 KB
testcase_19 AC 623 ms
5,452 KB
testcase_20 AC 654 ms
5,452 KB
testcase_21 AC 616 ms
5,580 KB
testcase_22 AC 627 ms
5,452 KB
testcase_23 AC 637 ms
5,452 KB
testcase_24 AC 626 ms
5,580 KB
testcase_25 AC 616 ms
5,576 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 509 ms
5,448 KB
testcase_28 AC 500 ms
5,452 KB
testcase_29 AC 503 ms
5,452 KB
testcase_30 AC 502 ms
5,452 KB
testcase_31 AC 508 ms
5,448 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 261 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<tuple>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;


int main(){
    int N;
    cin>>N;

    vector<ll> ans;

    for(int i=0;i<N;i++){
        ll A,B;
        cin>>A>>B;

        ll ub=1LL<<30;//ubは必ず満たす
        ll lb=0;


        auto f=[&](ll x){

            if((x*x-A-B)<=0) return false;

            return (4*A*B/(x*x-A-B)) < (x*x-A-B);
        };

        int cnt=0;

        while(ub-lb>1){

            //if(cnt>30) break;

            //cnt++;
            ll mid=(ub+lb)/2;
            //cout<<"mid="<<mid<<endl;

            if(f(mid)){
                //midは条件を満たす
                ub=mid;
            }else{
                lb=mid;
            }
        }
        ans.push_back(ub);

    }

    for(ll v:ans){
        cout<<v<<endl;
    }

}
0