結果

問題 No.3180 angles sum
ユーザー areik
提出日時 2025-06-13 22:12:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,551 bytes
コンパイル時間 3,649 ms
コンパイル使用メモリ 252,028 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-14 01:42:33
合計ジャッジ時間 6,597 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

using i32 = int;
using i64 = long long;
using f64 = long double;
using i128 = __int128_t;
using p2 = pair<i128, i128>;
using el = tuple<i128, i128, i128>;
using mint = atcoder::modint998244353;

void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}

i128 pow(i128 x, i128 n, i128 m) {
  i128 res = 1;
  i128 t = x % m;
  while (n > 0) {
    if (n & 1) {
      res = res * t % m;
    }
    t = t * t % m;
    n >>= 1;
  }
  return res;
}

void _main() {
  i64 t;
  cin >> t;
  for (;t--;) {
    i128 ax, ay, bx, by, cx, cy;
    {
      i64 axx,ayy,bxx,byy,cxx,cyy;
      cin >> axx >> ayy >> bxx >> byy >> cxx >> cyy;
      ax = axx, ay = ayy, bx = bxx, by = byy, cx = cxx, cy = cyy;
    }
    // (ax + ayi)(bx + byi) / (|a||b|) == (cx + cyi) / |c|
    // (ax*bx - ay*by + (ax*by + ay*bx)i) / (|a||b|) == (cx + cyi) / |c|
    // ax*bx - ay*by / AB == cx / C && ax*by + ay*bx / AB == cy / C
    bool ok = true;
    {
      i128 x = ax * bx - ay * by; // 2
      i128 y = cx; // 1
      i128 p = (ax*ax + ay*ay) * (bx*bx + by*by); // 4
      i128 q = cx * cx + cy * cy; // 2
      if (x * y < 0) ok = false;
      x *= x, y *= y; // 4 2
      ok &= x * q == y * p; // 6 6
    }
    {
      i128 x = ax * by + ay * bx;
      i128 y = cy;
      i128 p = (ax*ax + ay*ay) * (bx*bx + by*by);
      i128 q = cx * cx + cy * cy;
      if (x * y < 0) ok = false;
      x *= x, y *= y;
      ok &= x * q == y * p;
    }
    cout << (ok ? "Yes\n" : "No\n");
  }
}
0