結果

問題 No.2420 Simple Problem
ユーザー zezerozezero
提出日時 2023-08-12 14:40:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 860 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 3,439 ms
コンパイル使用メモリ 177,936 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 06:52:05
合計ジャッジ時間 30,471 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 348 ms
6,940 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 130 ms
6,940 KB
testcase_04 AC 673 ms
6,944 KB
testcase_05 AC 435 ms
6,940 KB
testcase_06 AC 843 ms
6,940 KB
testcase_07 AC 840 ms
6,940 KB
testcase_08 AC 845 ms
6,944 KB
testcase_09 AC 855 ms
6,944 KB
testcase_10 AC 848 ms
6,944 KB
testcase_11 AC 844 ms
6,944 KB
testcase_12 AC 844 ms
6,940 KB
testcase_13 AC 854 ms
6,940 KB
testcase_14 AC 852 ms
6,944 KB
testcase_15 AC 856 ms
6,940 KB
testcase_16 AC 846 ms
6,944 KB
testcase_17 AC 839 ms
6,944 KB
testcase_18 AC 851 ms
6,940 KB
testcase_19 AC 836 ms
6,944 KB
testcase_20 AC 854 ms
6,944 KB
testcase_21 AC 844 ms
6,940 KB
testcase_22 AC 849 ms
6,940 KB
testcase_23 AC 856 ms
6,940 KB
testcase_24 AC 850 ms
6,940 KB
testcase_25 AC 860 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 668 ms
6,940 KB
testcase_28 AC 672 ms
6,940 KB
testcase_29 AC 674 ms
6,944 KB
testcase_30 AC 671 ms
6,944 KB
testcase_31 AC 679 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 338 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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