結果

問題 No.2420 Simple Problem
ユーザー m_99m_99
提出日時 2023-08-12 13:45:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 636 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 4,119 ms
コンパイル使用メモリ 227,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 04:00:43
合計ジャッジ時間 25,417 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 263 ms
5,376 KB
testcase_02 AC 24 ms
5,376 KB
testcase_03 AC 97 ms
5,376 KB
testcase_04 AC 495 ms
5,376 KB
testcase_05 AC 326 ms
5,376 KB
testcase_06 AC 628 ms
5,376 KB
testcase_07 AC 627 ms
5,376 KB
testcase_08 AC 631 ms
5,376 KB
testcase_09 AC 623 ms
5,376 KB
testcase_10 AC 624 ms
5,376 KB
testcase_11 AC 632 ms
5,376 KB
testcase_12 AC 622 ms
5,376 KB
testcase_13 AC 623 ms
5,376 KB
testcase_14 AC 629 ms
5,376 KB
testcase_15 AC 633 ms
5,376 KB
testcase_16 AC 625 ms
5,376 KB
testcase_17 AC 632 ms
5,376 KB
testcase_18 AC 636 ms
5,376 KB
testcase_19 AC 625 ms
5,376 KB
testcase_20 AC 626 ms
5,376 KB
testcase_21 AC 619 ms
5,376 KB
testcase_22 AC 621 ms
5,376 KB
testcase_23 AC 628 ms
5,376 KB
testcase_24 AC 622 ms
5,376 KB
testcase_25 AC 628 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 497 ms
5,376 KB
testcase_28 AC 504 ms
5,376 KB
testcase_29 AC 496 ms
5,376 KB
testcase_30 AC 493 ms
5,376 KB
testcase_31 AC 494 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 249 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		
		long long a,b;
		cin>>a>>b;
		
		__int128 ok = 4100000000;
		__int128 ng = 0;
		while(ok-ng>1){
			__int128 mid = (ok+ng)/2;
			__int128 t = mid*mid;
			t -= a+b;
			//cout<<(long long)mid<<','<<(long long)t<<endl;
			if(t<=0){
				ng = mid;
				continue;
			}
			t *= t;
			t -= a*b*4;
			//cout<<(long long)mid<<','<<(long long)t<<endl;
			if(t > 0)ok = mid;
			else ng = mid;
		}
		cout<<(long long)ok<<endl;
		
	}
	return 0;
}
0