codeforces 851 B. Arpa and an exam about geometry
2017-09-05 22:45
375 查看
脑袋短路了,只要判断AB和BC距离是否同样就好了。写的时候有点短路,判断多了。。
#include <bits/stdc++.h> using namespace std; typedef long long LL; const double eps = 1e-8; struct Point { Point(){} Point(double _a, double _b):x(_a),y(_b){} double x,y; }; Point ps[3]; int sgn(double x) { if(fabs(x) <= eps) return 0; if(x > 0) return 1; return -1; } double dist(Point a, Point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } bool check() { Point cen((ps[0].x+ps[2].x)/2.0,(ps[0].y+ps[2].y)/2.0); Point ac(ps[2].x-ps[0].x,ps[2].y-ps[0].y); Point cenb(ps[1].x-cen.x,ps[1].y-cen.y); double t = ac.x*cenb.x+ac.y*cenb.y; Point ab(ps[1].x-ps[0].x,ps[1].y-ps[0].y); Point bc(ps[2].x-ps[1].x,ps[2].y-ps[1].y); double cj = ab.x*bc.y-ab.y*bc.x; return sgn(t)==0 && sgn(cj) != 0; } int main() { ios::sync_with_stdio(false); for(int i = 0; i < 3; ++i) cin >> ps[i].x >> ps[i].y; double dis1,dis2,dis3; dis1 = dist(ps[0],ps[1]); dis2 = dist(ps[0],ps[2]); dis3 = dist(ps[1],ps[2]); if((sgn(dis1-dis2) == 0 || sgn(dis1-dis3) == 0 || sgn(dis2-dis3) == 0) && check()) cout << "Yes" <<endl; else cout << "No" << endl; return 0; }
相关文章推荐
- Codeforces 851 B Arpa and an exam about geometry
- Codeforces 851B - Arpa and an exam about geometry - 数学几何
- Codeforces 851B && Round #432 Div. 2 B. Arpa and an exam about geometry
- codeforce 851 B Arpa and an exam about geometry(思路)
- 【Codeforces Round #432 (Div. 2) B】Arpa and an exam about geometry
- codeforces Div#432 B Arpa and an exam about geometry(技巧)
- 【推导】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B. Arpa and an exam about geometry
- Codeforces Round #432 Div2 B. Arpa and an exam about geometry
- Codeforces Round #432 (Div. 2) B. Arpa and an exam about geometry(数学水题)
- Codeforces Round#432 B. Arpa and an exam about geometry
- B - Arpa and an exam about geometry
- Codeforces Round #432 (Div. 2) - B - Arpa and an exam about geometry
- Codeforces Round #432 (Div. 2) B Arpa and an exam about geometry
- B. Arpa and an exam about geometry
- Codeforces 851 A Arpa and a research in Mexican wave
- Codeforces 742A-Arpa’s hard exam and Mehrdad’s naive cheat(快速幂)
- Codeforces 851 D. Arpa and a list of numbers(技巧)
- codeforces 851 D. Arpa and a list of numbers(前缀和+bruteforce)
- 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat
- Methods to transform made the effort and additionally wedding date about Diesel-engined keep an eye on