結果

問題 No.2765 Cross Product
ユーザー tnakao0123tnakao0123
提出日時 2024-06-01 11:37:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,355 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 43,136 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-01 11:37:52
合計ジャッジ時間 1,472 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2765.cc:  No.2765 Cross Product - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

template <typename T>
struct Pt3d {
  T x, y, z;

  Pt3d() {}
  Pt3d(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}
  Pt3d(const Pt3d& pt) : x(pt.x), y(pt.y), z(pt.z) {}

  bool operator==(const Pt3d pt) const {
    return x == pt.x && y == pt.y && z == pt.z;
  }
  Pt3d<T> operator+(const Pt3d pt) const {
    return Pt3d<T>(x + pt.x, y + pt.y, z + pt.z);
  }
  Pt3d<T> operator-() const {
    return Pt3d<T>(-x, -y, -z);
  }
  Pt3d<T> operator-(const Pt3d pt) const {
    return Pt3d<T>(x - pt.x, y - pt.y, z - pt.z);
  }
  Pt3d<T> operator*(T t) const {
    return Pt3d<T>(x * t, y * t, z * t);
  }
  Pt3d<T> operator/(T t) const {
    return Pt3d<T>(x / t, y / t, z / t);
  }
  T dot(Pt3d v) const { return x * v.x + y * v.y + z * v.z; }
  Pt3d<T> cross(Pt3d v) const {
    return Pt3d<T>(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
  }
};

typedef Pt3d<int> pt3d;

/* subroutines */

void readpt(pt3d &p) { scanf("%d%d%d", &p.x, &p.y, &p.z); }
void printpt(pt3d &p) { printf("%d %d %d\n", p.x, p.y, p.z); }

/* global variables */

/* subroutines */

/* main */

int main() {
  pt3d a, b;
  readpt(a), readpt(b);

  pt3d c = a.cross(b);
  printpt(c);
  
  return 0;
}
0