結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 14:40:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 865 ms / 2,000 ms |
| コード長 | 785 bytes |
| コンパイル時間 | 3,140 ms |
| コンパイル使用メモリ | 170,096 KB |
| 最終ジャッジ日時 | 2025-02-16 05:12:47 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
void solve(){
ll a,b;
cin >> a >> b;
ll ok = 1e18;
ll ng = a+b;
while(ok-ng > 1LL){
ll mid = (ok+ng)/2;
if (mid-a-b < 0){
ng = mid;
continue;
}
else if (4*a*b/(mid-a-b) < (mid-a-b)){
ok = mid;
continue;
}
else{
ng = mid;
continue;
}
}
ll ans = round(sqrtl(ok));
if (ans*ans < ok) ans++;
cout << ans << endl;
//cout << round(sqrtl(ok)) << endl;
}
int main(){
int tt;
cin >> tt;
while(tt--){
solve();
}
return 0;
}