結果

問題 No.1064 ∪∩∩ / Cup Cap Cap
コンテスト
ユーザー a01sa01to
提出日時 2026-01-04 01:09:31
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,034 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,421 ms
コンパイル使用メモリ 334,436 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-04 01:09:37
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

inline ll sqr(ll x) { return x * x; }

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll det = sqr(a - c) - 8 * (b - d);
  if (det < 0) {
    cout << "No" << '\n';
  }
  else if (det == 0) {
    cout << "Yes" << '\n';
  }
  else {
    long double sqrtdet = sqrtl(det);
    auto f = [&](long double x) {
      return x * x + a * x + b;
    };
    auto g = [&](long double x) {
      return -x * x + c * x + d;
    };
    long double x1 = (-(a - c) - sqrtdet) / 4;
    long double x2 = (-(a - c) + sqrtdet) / 4;
    assert(abs(f(x1) - g(x1)) < 1e-9);
    assert(abs(f(x2) - g(x2)) < 1e-9);
    long double y1 = f(x1), y2 = f(x2);
    long double p = (y2 - y1) / (x2 - x1);
    long double q = y1 - p * x1;
    assert(abs((y2 - p * x2) - q) < 1e-9);
    cout << fixed << setprecision(15) << p << ' ' << q << '\n';
  }
  return 0;
}
0