結果

問題 No.2420 Simple Problem
ユーザー ku_senjan
提出日時 2023-08-12 14:24:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,490 bytes
コンパイル時間 25,819 ms
コンパイル使用メモリ 486,536 KB
最終ジャッジ日時 2025-02-16 04:46:11
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef SENJAN
#define _GLIBCXX_DEBUG
#else
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using bint = boost::multiprecision::cpp_int;
using graph=vector<vector<int>>;
template<class T> using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
constexpr int INF32=INT_MAX/2;
constexpr ll INF64=LLONG_MAX/2;
constexpr ld PI=3.14159265358979323846;
constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1};
template<class T> inline bool chmax(T &a,T b){return a<b?a=b,true:false;}
template<class T> inline bool chmin(T &a,T b){return a>b?a=b,true:false;}
inline void dispYN(bool a){cout<<(a?"YES":"NO")<<endl;}
inline void dispYn(bool a){cout<<(a?"Yes":"No")<<endl;}
inline void dispyn(bool a){cout<<(a?"yes":"no")<<endl;}
void _main();
int main(){cin.tie(0)->sync_with_stdio(0);cout<<fixed<<setprecision(16);_main();}

void _main(){
  int n; cin >> n;
  while(n--){
    ll a, b; cin >> a >> b;
    // square = a+b+2*sqrt(a*b)
    ll l1=0, r1=1LL<<30;
    while(r1-l1>1){
      ll m = (l1+r1)/2;
      if(m*m<=4*a*b) l1=m;
      else r1=m;
    }
    // sqare < a+b+r1
    ll l2=0, r2=1LL<<30;
    while(r2-l2>1){
      ll m=(l2+r2)/2;
      if(m*m<a+b+r1) l2=m;
      else r2=m;
    }
    cout << r2 << endl;
  }
}
0