\overrightarrow{AB}\times\overrightarrow{AC}判断点C的位置,若为正则在左侧,若为负则在右侧,若为零,继续判断,若0\le\overrightarrow{AB}\cdot\overrightarrow{AC}\le\!\left(\overrightarrow{AB}\right)^2则 C 在 AB 上。

#include <iostream>
using namespace std;

using ll = long long;

struct Point {
    ll x;
    ll y;
    void Input() {
        cin >> x >> y;
    }
    ll Len2() const {
        return x * x + y * y;
    }
};

Point operator-(const Point& a, const Point& b) {
    return {a.x - b.x, a.y - b.y};
}

ll Cha(const Point& a, const Point& b) {
    return a.x * b.y - a.y * b.x;
}

ll Dian(const Point& a, const Point& b) {
    return a.x * b.x + a.y * b.y;
}

Point A, B, C;
Point AB;
Point AC;

void Solve() {
    A.Input();
    B.Input();
    C.Input();
    AB = B - A;
    AC = C - A;
    ll cha = Cha(AB, AC);
    if (cha > 0) {
        cout << "1\n";
        return;
    }
    if (cha < 0) {
        cout << "2\n";
        return;
    }
    ll len2 = AB.Len2();
    ll dian = Dian(AB, AC);
    if (dian > len2 || dian < 0) {
        cout << "4\n";
        return;
    }
    cout << "3\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--) {
        Solve();
    }
}
// 64 位输出请用 printf("%lld")