結果
問題 | No.2420 Simple Problem |
ユーザー |
|
提出日時 | 2023-07-11 14:30:49 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 576 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 127,744 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-13 04:55:05 |
合計ジャッジ時間 | 19,901 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
#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; }