結果

問題 No.2420 Simple Problem
ユーザー ochiaigawa
提出日時 2023-08-12 14:12:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 194,008 KB
最終ジャッジ日時 2025-02-16 04:22:26
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  while(N--) {
    long long A, B;
    cin >> A >> B;
    long long X = sqrt(sqrt(A * B * 4) + A + B);
    long long ans = X + 100;
    for(long long i = max((long long) 0, X - 10); i <= X + 10; i++) {
      if(A * B * 4 < (i * i - A - B) * (i * i - A - B) && i * i > A + B) {
        ans = min(ans, i);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
0