結果

問題 No.2420 Simple Problem
ユーザー zezerozezero
提出日時 2023-08-12 14:40:27
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 794 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 3,167 ms
コンパイル使用メモリ 176,328 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 20:50:27
合計ジャッジ時間 27,007 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

void solve(){
	ll a,b;
	cin >> a >> b;
	ll ok = 1e18;
	ll ng = a+b;
	while(ok-ng > 1LL){
		ll mid = (ok+ng)/2;
		if (mid-a-b < 0){
			ng = mid;
			continue;
		}
		else if (4*a*b/(mid-a-b) < (mid-a-b)){
			ok = mid;
			continue;
		}
		else{
			ng = mid;
			continue;
		}
	}
	ll ans = round(sqrtl(ok));
	if (ans*ans < ok) ans++;
	cout << ans << endl;
	//cout << round(sqrtl(ok)) << endl;
}
int main(){
	int tt;
	cin >> tt;
	while(tt--){
		solve();
	}
	
	
	return 0;
}
0