結果

問題 No.2420 Simple Problem
ユーザー umezoumezo
提出日時 2023-08-12 14:13:54
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,133 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 8,656 ms
コンパイル使用メモリ 453,828 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-19 18:01:17
合計ジャッジ時間 41,443 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef unsigned long long ll;
 
#include<bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

Bint f(Bint a,Bint b){
  Bint ok=70000,ng=0;
  while(ok-ng>1){
    Bint m=(ok+ng)/2;
    if(m*m-a-b<0) ng=m;
    else if(m*m*m*m+a*a+b*b>2*(a*m*m+b*m*m+a*b)) ok=m;
    else ng=m;
  }
  return ok;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  rep(i,n){
    Bint a,b;
    cin>>a>>b;
    cout<<f(a,b)<<'\n';
  }
    
  return 0;
}
0