日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Ampzz 2011 Cross Spider 计算几何

發(fā)布時間:2025/7/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ampzz 2011 Cross Spider 计算几何 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原題鏈接:http://codeforces.com/gym/100523/attachments/download/2798/20142015-ct-s02e07-codeforces-trainings-season-2-episode-7-en.pdf

題意

給你一堆三維點(diǎn),問你他們是否共面

題解

模板題,套版就好,需要注意的是共線

代碼

#include<iostream> #include<cmath> #include<cstdio> #define MAX_N 100005 using namespace std;const double eps=1e-10;inline double Sqrt(double a) {return a <= 0 ? 0 : sqrt(a); }inline double Sqr(double a) {return a * a; }class Point_3 { public:double x, y, z;Point_3() { }Point_3(double xx, double yy, double zz) : x(xx), y(yy), z(zz) { }Point_3 operator-(Point_3 a) {return Point_3(x - a.x, y - a.y, z - a.z);}double Length() const {return Sqrt(Sqr(x) + Sqr(y) + Sqr(z));} };Point_3 Det(const Point_3 &a,const Point_3 &b) {return Point_3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); }double Dot(const Point_3 &a,const Point_3 &b) {return a.x * b.x + a.y * b.y + a.z * b.z; }double vlen(Point_3 P){return P.Length();}int dot_inline(Point_3 p1,Point_3 p2,Point_3 p3) {return vlen(Det(p1 - p2, p2 - p3)) < eps; }bool zero(double x) {return fabs(x) < eps; }Point_3 pvec(Point_3 s1,Point_3 s2,Point_3 s3) {return Det((s1 - s2), (s2 - s3)); }int dots_onplane(Point_3 a,Point_3 b,Point_3 c,Point_3 d) {return zero(Dot(pvec(a, b, c), d - a)); }int n; Point_3 point3[MAX_N];int main() {scanf("%d", &n);for (int i = 0; i < n; i++) {int a, b, c;scanf("%d%d%d", &a, &b, &c);point3[i] = Point_3(a, b, c);}if (n <= 3) {cout << "TAK" << endl;return 0;}int p = -1;for (int i = 2; i < n; i++) {if (dot_inline(point3[0], point3[1], point3[i]) == 0) {p = i;break;}}if (p == -1) {cout << "TAK" << endl;return 0;}for (int i = 2; i < n; i++) {if (i == p)continue;if (dots_onplane(point3[0], point3[1], point3[p], point3[i]) == 0) {cout << "NIE" << endl;return 0;}}cout << "TAK" << endl;return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/HarryGuo2012/p/4730935.html

總結(jié)

以上是生活随笔為你收集整理的Ampzz 2011 Cross Spider 计算几何的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。