結果

問題 No.2420 Simple Problem
ユーザー millfi_millfi_
提出日時 2023-08-12 15:37:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 548 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 166,684 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 09:54:01
合計ジャッジ時間 19,271 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 220 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 80 ms
6,940 KB
testcase_04 AC 417 ms
6,940 KB
testcase_05 AC 270 ms
6,944 KB
testcase_06 AC 528 ms
6,940 KB
testcase_07 AC 530 ms
6,944 KB
testcase_08 AC 539 ms
6,940 KB
testcase_09 AC 535 ms
6,940 KB
testcase_10 AC 548 ms
6,940 KB
testcase_11 AC 522 ms
6,944 KB
testcase_12 AC 532 ms
6,940 KB
testcase_13 AC 548 ms
6,940 KB
testcase_14 AC 535 ms
6,944 KB
testcase_15 AC 540 ms
6,944 KB
testcase_16 AC 538 ms
6,940 KB
testcase_17 AC 539 ms
6,940 KB
testcase_18 AC 528 ms
6,940 KB
testcase_19 AC 534 ms
6,940 KB
testcase_20 AC 539 ms
6,944 KB
testcase_21 AC 529 ms
6,944 KB
testcase_22 AC 537 ms
6,944 KB
testcase_23 AC 525 ms
6,944 KB
testcase_24 AC 530 ms
6,944 KB
testcase_25 AC 535 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 428 ms
6,944 KB
testcase_28 AC 426 ms
6,944 KB
testcase_29 AC 421 ms
6,940 KB
testcase_30 AC 418 ms
6,944 KB
testcase_31 AC 426 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 216 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(int i = 0; i < (int)(n); ++i)
#define rep2(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep3(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep4(i, a, b, c) for(int i = (a); i < (int)(b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u16 = uint16_t;
int main(){
	int N;
	cin >> N;
	auto isok = [](__int128_t x, __int128_t a, __int128_t b){
		if((x*x - a - b) < 0)return false;
		else if(4*a*b < (x*x - a - b) )return true;
		else return 4*a*b < ((x*x - a - b) * (x*x - a - b));
	};
	rep(i,N){
		ll a,b;
		cin >> a >> b;
		ll ok = 1000'000'000ll;
		ll ng = 1;
		while(abs(ok - ng) > 1ll){
			ll mid = (ok + ng)/2ll;
			if(isok(mid, a, b))ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
}
0