codeforces 1C. Ancient Berland Circus
二次联通门 : codeforces 1C. Ancient Berland Circus
/* c题 封装起来就WA 拿出来就A了 无奈 以一个场地遗迹,呈现多边形,但是不知道具体是几边形, 只知道他的三个点,求能包含这三个点的最小正多边形的面积: 分别求出三个点之间的距离 先求出他的外接圆,得到外接圆的半径r 有给定的坐标求出三条边的边长,s_1,s_2,s_3; 又海伦公式得到三角形的面积: 周长p = (s_1+s_2+s_3)/2.0 面积等于: S=sqrt(p*(p-s_1)*(p-s_2)*(p-s_3)); r=s_1*s_2*s_3/(4*S) 得到外接园的半径之后: 我们再来求出每一条边对应的圆心角a,b,c; 求出a,b,c圆心角的最大公约数p; 这样我们就可以知道他是边数: 2*pi/p; 所以得到最小单位的三角形的面积为Area=r*r*sin(p)/2; 总面积只需再剩上他的边数就可以得到 */ #include <cstdio> #include <cmath> #define Max 5 #define EPS 0.01 #define PI 3.14159265358 /* class Point_Type { private : struct Point_Date { double x; double y; } point[Max]; struct Line_Date { double k; double b; }line[Max]; double Get_Gcd (double a, double b) { return a < EPS ? b : Get_Gcd (fmod (b, a), a); } double Get_k (Point_Date a, Point_Date b) { return (a.y - b.y) / (a.x - b.x); } double Get_Range (Point_Date a, Point_Date b) { return sqrt ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } Point_Date Get_Mid_Point_Pos (Point_Date a, Point_Date b) { Point_Date now; now.x = (a.x + b.x) / 2.0; now.y = (a.y + b.y) / 2.0; } void swap (double &a, double &b) { double now; a = b; b = now; } public : void Insert_Date () { for (int i = 1; i <= 3; i++) { scanf ("%lf", &point[i].x); scanf ("%lf", &point[i].y); } } void Get_3_line () { Point_Date now; for (int i = 1; i <= 2; i++) { now = Get_Mid_Point_Pos (point[i], point[i + 1]); line[i].k = -1.0 / Get_k (point[i], point[i + 1]); line[i].b = (now.y - line[i].k * now.x); } now = Get_Mid_Point_Pos (point[3], point[1]); line[3].k = -1.0 / Get_k (point[3], point[1]); line[3].b = (now.y - line[3].k * now.x); } void MMP () { // Get_3_line (); } }; Point_Type Make; */ struct Point_Date { double x; double y; } point[Max]; double Get_Range (Point_Date a, Point_Date b) { return sqrt ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } bool swap (double &a, double &b) { double now = a; a = b; b = now; } double Get_Gcd (double a, double b) { return a < EPS ? b : Get_Gcd (fmod (b, a), a); } int main (int argc, char *argv[]) { for (int i = 1; i <= 3; i++) { scanf ("%lf", &point[i].x); scanf ("%lf", &point[i].y); } double s_1, s_2, s_3; s_1 = Get_Range (point[1], point[2]); s_2 = Get_Range (point[2], point[3]); s_3 = Get_Range (point[3], point[1]); double p = (s_1 + s_2 + s_3) / 2.0; double S = sqrt (p * (p - s_1) * (p - s_2) * (p - s_3)); double r = (s_1 * s_2 * s_3) / (4.0 * S); if (s_1 > s_3) swap (s_1, s_3); if (s_2 > s_3) swap (s_2, s_3); double G_1 = 2.0 * asin (s_1 / (2.0 * r)); double G_2 = 2.0 * asin (s_2 / (2.0 * r)); double G_3 = 2.0 * PI - G_1 - G_2; p = Get_Gcd (G_1, G_2); p = Get_Gcd (p, G_3); printf ("%.6lf", (PI * r * r * sin (p)) / p); return 0; }
myj 吊打我Orz,xxy 捆起来打我Orz,myl 文化课上天Orz, lrh 姿势水平敲高Orz, hkd 特别胖Orz%%%,cys 智商感人Orz,syl zz专业Orz,我没有学上, 我们未来一片光明