Codeforces Beta Round #1 练习
来源:互联网 发布:数据挖掘 数学基础 编辑:程序博客网 时间:2024/06/05 13:40
A 大水题
B 模拟题,要很小心,注意细节处理
C 给你在一个正多边形上的三个点,判断这个多边形的最小面积。
由于这个多边形最多只有100条边,可以直接枚举多边形的边数计算是否满足
判断是否满足:
三个点组成的三角形的每个角是圆周角的整数倍
判断整数的时候精度不宜太大
View Code
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>using namespace std;const double eps = 1e-8;const double pi = acos(-1.0);double dist(double x1,double y1,double x2,double y2){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}double cross(double x1,double y1,double x2,double y2,double x3,double y3){ return (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);}bool ok(int n,double ang){ double tmp=ang*n/pi;//判断tmp是否是一个整数 double x=floor(tmp+1e-3);//精度不宜过大,这里WA了一次 if(tmp-x<1e-3) return true; return false;}int main(){ double x1,x2,y1,y2,x3,y3; while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF) { double a=dist(x1,y1,x2,y2); double b=dist(x2,y2,x3,y3); double c=dist(x1,y1,x3,y3); double s=cross(x1,y1,x2,y2,x3,y3); double R=a*b*c/2/s; double C=acos((a*a+b*b-c*c)/(2*a*b)); double B=acos((a*a+c*c-b*b)/(2*a*c)); double A=acos((b*b+c*c-a*a)/(2*b*c)); // printf("%.2lf %.2lf %.2lf\n",A,B,C); int n; for(n=3;n<=100;n++) if(ok(n,A)&&ok(n,B)&&ok(n,C)) break; //printf("n=%d\n",n); double cen=2*pi/n; double ans=R*R*0.5*sin(cen)*n; printf("%lf\n",ans); } return 0;}
- Codeforces Beta Round #1 练习
- Codeforces Beta Round #2 练习
- Codeforces Beta Round #3 练习
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1 ABC
- Codeforces Beta Round #1(A,B)
- Codeforces Beta Round #83 (Div. 1 Only)
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A题
- Codeforces Beta Round #1 A B C
- hdu 3271 数位统计 的 DP
- codeforces 练习 ---- CF 24
- poj 2761 Feed the dogs 求区间第k大的数
- hdu 3333 Turing Tree 成段不重复求和
- Android内存泄露问题(一)之context的引用
- Codeforces Beta Round #1 练习
- Codeforces Beta Round #2 练习
- zoj 3228 Searching the String
- 织梦会员系统bug
- light oj 1427 AC自动机+dfs
- Codeforces Beta Round #3 练习
- CF 4 练习
- 背包输出方案 Pro-Test Voting
- light oj 1135 线段树 有助于加深对懒惰标记的理解