复数

const db pi = acos(-1);
struct com {
    db x, y;
    com() {x = y = 0; }
    com(db _x, db _y) {x = _x, y = _y; }
    com(db r) {
        x = cos(r), y = sin(r); 
    }
    friend com operator + (const com a, const com b) {
        return com(a.x + b.x, a.y + b.y);
    }
    friend com operator - (const com a, const com b) {
        return com(a.x - b.x, a.y - b.y);
    }
    friend com operator * (const com a, const com b) {
        return com(a.x * b.x - a.y * b.y, a.y * b.x + a.x * b.y);
    }
};
posted @ 2022-01-01 19:49  SegmentTree  阅读(41)  评论(0编辑  收藏  举报