結果

問題 No.1064 ∪∩∩ / Cup Cap Cap
ユーザー HaarHaar
提出日時 2020-05-29 21:42:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 196,344 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 20:54:07
合計ジャッジ時間 3,350 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...)
#endif

const long double eps = 1e-7;

/**
 * @title 二次方程式の実数解
 * @docs quadratic_equation.md
 */
std::vector<long double> quadratic_equation(long double a, long double b, long double c){
  long double d = b*b - 4*a*c;
  if(d < 0) return {};

  long double x1 = (-b + std::sqrt(d)) / (2 * a);
  long double x2 = (-b - std::sqrt(d)) / (2 * a);
  return {x1, x2};
}


int main(){
  int a, b, c, d;

  while(std::cin >> a >> b >> c >> d){

    int64_t A = 2;
    int64_t B = a-c;
    int64_t C = b-d;
    int64_t D = B * B - 4LL * A * C;

    if(D < 0){
      std::cout << "No\n";
    }else if(D == 0){
      std::cout << "Yes\n";
    }else{
      auto res = quadratic_equation(2.0, a-c, b-d);

      auto x1 = res[0], x2 = res[1];
      auto y1 = x1 * x1 + x1 * a + b;
      auto y2 = x2 * x2 + x2 * a + b;

      auto p = (y2 - y1) / (x2 - x1);
      auto q = y1 - p * x1;

      std::cout << std::fixed << std::setprecision(12) << p << " " << q << "\n";
    }
  }

  return 0;
}
0