結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2023-08-12 14:13:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,210 ms / 2,000 ms |
| コード長 | 693 bytes |
| コンパイル時間 | 9,082 ms |
| コンパイル使用メモリ | 464,208 KB |
| 最終ジャッジ日時 | 2025-02-16 04:24:10 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
#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;
}
umezo