結果

問題 No.2420 Simple Problem
ユーザー simansiman
提出日時 2023-08-20 19:58:56
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 630 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 4,269 ms
コンパイル使用メモリ 105,912 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-08-20 19:59:24
合計ジャッジ時間 27,154 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,880 KB
testcase_01 AC 252 ms
4,952 KB
testcase_02 AC 4 ms
4,888 KB
testcase_03 AC 92 ms
4,888 KB
testcase_04 AC 476 ms
4,888 KB
testcase_05 AC 304 ms
4,892 KB
testcase_06 AC 627 ms
4,888 KB
testcase_07 AC 600 ms
4,884 KB
testcase_08 AC 625 ms
4,888 KB
testcase_09 AC 608 ms
4,948 KB
testcase_10 AC 610 ms
4,888 KB
testcase_11 AC 605 ms
4,952 KB
testcase_12 AC 608 ms
4,952 KB
testcase_13 AC 606 ms
4,952 KB
testcase_14 AC 606 ms
4,892 KB
testcase_15 AC 605 ms
4,948 KB
testcase_16 AC 604 ms
4,884 KB
testcase_17 AC 630 ms
4,888 KB
testcase_18 AC 603 ms
4,884 KB
testcase_19 AC 622 ms
4,952 KB
testcase_20 AC 607 ms
4,952 KB
testcase_21 AC 628 ms
4,948 KB
testcase_22 AC 606 ms
4,892 KB
testcase_23 AC 610 ms
4,884 KB
testcase_24 AC 605 ms
4,892 KB
testcase_25 AC 604 ms
4,956 KB
testcase_26 AC 1 ms
4,888 KB
testcase_27 AC 480 ms
4,888 KB
testcase_28 AC 473 ms
4,884 KB
testcase_29 AC 482 ms
4,948 KB
testcase_30 AC 509 ms
4,380 KB
testcase_31 AC 476 ms
4,884 KB
testcase_32 AC 2 ms
4,952 KB
testcase_33 AC 242 ms
4,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;

    ll ok = 1000000000;
    ll ng = 0;

    while (abs(ok - ng) >= 2) {
      __int128 x = (ok + ng) / 2;
      __int128 v = x * x - (a + b);

      if (v >= 0 && 4 * a * b < v * v) {
        ok = x;
      } else {
        ng = x;
      }
    }

    cout << ok << endl;
  }

  return 0;
}
0