結果
問題 | No.2420 Simple Problem |
ユーザー |
![]() |
提出日時 | 2023-08-12 14:25:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 568 ms / 2,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 1,871 ms |
コンパイル使用メモリ | 166,280 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-19 19:19:56 |
合計ジャッジ時間 | 20,260 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;ll sqrtll(ll x){assert(x >= 0);ll n = sqrt(x);while(n * n > x) --n;while((n+1)*(n+1) <= x) ++n;return n;}int main(){// inputint N; cin >> N;while(N--){ll A,B; cin >> A >> B;// solve: meguru binary searchll lo = max(sqrtll(A),sqrtll(B)), hi = 1e6;while(hi - lo > 1){ll mid = (lo + hi) / 2;ll lhs = mid * mid - (A + B);ll rhs = 4 * A * B;bool greater = (lhs > 3e9);if(!greater){if(lhs * lhs > rhs)greater = 1;}// judgeif(greater) hi = mid;else lo = mid;}// outputcout << hi << endl;}}