結果

問題 No.2420 Simple Problem
ユーザー ryota2357ryota2357
提出日時 2023-07-11 14:30:49
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 90,344 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 05:39:18
合計ジャッジ時間 18,970 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 223 ms
4,372 KB
testcase_02 AC 4 ms
4,348 KB
testcase_03 AC 84 ms
4,348 KB
testcase_04 AC 429 ms
4,356 KB
testcase_05 AC 275 ms
4,352 KB
testcase_06 AC 538 ms
4,348 KB
testcase_07 AC 534 ms
4,348 KB
testcase_08 AC 530 ms
4,348 KB
testcase_09 AC 544 ms
4,352 KB
testcase_10 AC 542 ms
4,348 KB
testcase_11 AC 543 ms
4,352 KB
testcase_12 AC 550 ms
4,352 KB
testcase_13 AC 539 ms
4,352 KB
testcase_14 AC 544 ms
4,356 KB
testcase_15 AC 526 ms
4,352 KB
testcase_16 AC 546 ms
4,352 KB
testcase_17 AC 545 ms
4,352 KB
testcase_18 AC 540 ms
4,352 KB
testcase_19 AC 533 ms
4,348 KB
testcase_20 AC 536 ms
4,352 KB
testcase_21 AC 531 ms
4,376 KB
testcase_22 AC 538 ms
4,376 KB
testcase_23 AC 542 ms
4,376 KB
testcase_24 AC 541 ms
4,372 KB
testcase_25 AC 543 ms
4,372 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 429 ms
4,376 KB
testcase_28 AC 423 ms
4,376 KB
testcase_29 AC 427 ms
4,376 KB
testcase_30 AC 427 ms
4,376 KB
testcase_31 AC 428 ms
4,376 KB
testcase_32 AC 2 ms
4,372 KB
testcase_33 AC 214 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;

void solve() {
    ll a, b;
    cin >> a >> b;
    ull min_x = max<ull>(1, sqrt(a) + sqrt(b) - 1);
    ull x = min_x;
    while(1) {
        ull x4 = x * x * x * x;
        ull sb = 2 * x * x * (a + b);
        ull ab2 = (max(a, b) - min(a, b)) * (max(a, b) - min(a, b));
        if (ab2 + x4 > sb) { // ab2 > sub - x4
            cout << x << endl;
            return;
        }
        x += 1;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        solve();
    }
    return 0;
}
0