結果

問題 No.2420 Simple Problem
ユーザー Ping Chung Chang
提出日時 2023-08-29 21:57:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 166,780 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 00:16:46
合計ジャッジ時間 8,135 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define ld long double



const ld sq = sqrt(1e9+10)*2;
const ld eps = 1e-8;

void solve(){
	ll a,b;
	cin>>a>>b;
	ll l = 0,r = sq+1;
	while(l != r){
		ll mid = (l+r)>>1;
		ll C = mid*mid-a-b;
		if(C<0)l = mid+1;
		else if(C*C>a*b*4)r = mid;
		else l = mid+1;
	}
	cout<<l<<'\n';
	return;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t;cin>>t;
	while(t--)solve();
}
0