結果

問題 No.2420 Simple Problem
コンテスト
ユーザー ryota2357
提出日時 2023-07-11 14:22:55
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 752 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,292 ms
コンパイル使用メモリ 140,860 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 03:29:10
合計ジャッジ時間 30,522 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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);
        if (a == b) {
            if (x4 > sb) { // x4 - sb > 0
                cout << x << endl;
                return;
            }
        } else {
            if (x4 >= sb) { // x4 - sb >= 0
                cout << x << endl;
                return;
            }
        }
        x += 1;
    }
}

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