• 数论


    给出三维空间上的四个点(点与点的位置均不相同),判断这4个点是否在同一个平面内(4点共线也算共面)。如果共面,输出"Yes",否则输出"No"。
    Input
    第1行:一个数T,表示输入的测试数量(1 <= T <= 1000)
    第2 - 4T + 1行:每行4行表示一组数据,每行3个数,x, y, z, 表示该点的位置坐标(-1000 <= x, y, z <= 1000)。
    Output
    输出共T行,如果共面输出"Yes",否则输出"No"。
    Input示例
    1
    1 2 0
    2 3 0
    4 0 0
    0 0 0
    Output示例
    Yes



    ---------------------------------------------------------我是分割线^_^--------------------------------------------------------


    什么都不说了,马上准备复习高数= =,四点共面就求出其中三条向量,利用三阶行列式判断,结果为零
    就是四点共面。


    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<vector>
    #include<queue>
    #include<cctype>
    using namespace std;

    #define Int __int64
    #define INF 0x3f3f3f3f

    int main()
    {
      //freopen("input.txt", "r", stdin);
      int cas;
      while (scanf("%d", &cas) != EOF) {
        while (cas--) {
          int x[5], y[5], z[5];
          for (int i = 1; i <= 4; i++) {
            scanf("%d %d %d", &x[i], &y[i], &z[i]);
          }
          int vx[4], vy[4], vz[4];
          vx[1] = x[1] - x[2], vy[1] = y[1] - y[2], vz[1] = z[1] - z[2];
          vx[2] = x[1] - x[3], vy[2] = y[1] - y[3], vz[2] = z[1] - z[3];
          vx[3] = x[1] - x[4], vy[3] = y[1] - y[4], vz[3] = z[1] - z[4];

          if (vx[1]*vy[2]*vz[3]-vx[1]*vz[2]*vy[3]-vy[1]*vx[2]*vz[3]+vy[1]*vz[2]*vx[3]+
          vz[1]*vx[2]*vy[3]-vz[1]*vy[2]*vx[3] == 0) {
            printf("Yes ");
          } else {
            printf("No ");
          }
        }
      }
    return 0;
    }

  • 相关阅读:
    & 微信支付对比
    # MySQL性能优化技巧
    & mysql简单定时增量全量备份
    & Mysql高级总结
    python面向对象
    django虚拟环境的安装
    Python 内置函数
    Python列表解析式
    函数练习
    Python装饰器
  • 原文地址:https://www.cnblogs.com/steamedbun/p/5757117.html
Copyright © 2020-2023  润新知