結果

問題 No.2420 Simple Problem
ユーザー maple_1016maple_1016
提出日時 2023-08-12 14:19:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 1,528 bytes
コンパイル時間 2,534 ms
コンパイル使用メモリ 183,880 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-30 05:43:34
合計ジャッジ時間 20,585 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 228 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 88 ms
6,944 KB
testcase_04 AC 455 ms
6,944 KB
testcase_05 AC 284 ms
6,940 KB
testcase_06 AC 561 ms
6,948 KB
testcase_07 AC 543 ms
6,940 KB
testcase_08 AC 537 ms
6,940 KB
testcase_09 AC 569 ms
6,940 KB
testcase_10 AC 570 ms
6,940 KB
testcase_11 AC 544 ms
6,940 KB
testcase_12 AC 569 ms
6,940 KB
testcase_13 AC 559 ms
6,940 KB
testcase_14 AC 553 ms
6,944 KB
testcase_15 AC 551 ms
6,944 KB
testcase_16 AC 555 ms
6,940 KB
testcase_17 AC 550 ms
6,940 KB
testcase_18 AC 576 ms
6,940 KB
testcase_19 AC 564 ms
6,944 KB
testcase_20 AC 554 ms
6,940 KB
testcase_21 AC 575 ms
6,940 KB
testcase_22 AC 534 ms
6,940 KB
testcase_23 AC 541 ms
6,940 KB
testcase_24 AC 543 ms
6,940 KB
testcase_25 AC 566 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 430 ms
6,940 KB
testcase_28 AC 433 ms
6,944 KB
testcase_29 AC 436 ms
6,944 KB
testcase_30 AC 448 ms
6,944 KB
testcase_31 AC 439 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 226 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
#define repr(i,n) for(ll i=2;i*i<=(n);++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) ((string)(x).size())
#define pb push_back
#define pob pop_back()
#define MMod (ll)1000000007
#define mmod (ll)998244353
#define setp(x) setprecision((ll)(x))
#define INF (ll)(1000000000000000000)
#define mp make_pair
using namespace std;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vc=vector<char>;
using vb=vector<bool>;
using vl=vector<long long>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vvc=vector<vc>;
using vvb=vector<vb>;
using vpi=vector<pii>;
using vpl=vector<pair<ll,ll>>;
using vs=vector<string>;
using pqi=priority_queue<int>;
vpi fs={mp(1,0),mp(-1,0),mp(0,1),mp(0,-1)};
const ll inf=1e18;

int main(){
    int n; cin>>n;
    rep(ii,n){
        ll a,b; cin>>a>>b;
        ll ok=a,ng=0;
        while(ok-ng>1){
            ll t=(ok+ng)/2;
            if(t*t>=a) ok=t;
            else ng=t;
        }
        ll ook=b,nng=0;
        while(ook-nng>1){
            ll t=(ook+nng)/2;
            if(t*t>=b) ook=t;
            else nng=t;
        }
        int aa=-1;
        while(1){
          ll k=ok+ook+aa;
          ll x=k*k-a-b;
          if(x*x>4*a*b) {
              cout<<k<<endl;
              break;
          }
          aa++;
        }
    }
  return 0;
}
0