Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我怎么WA了?这个公式不对么?In Reply To:有低于N^3的解法吗?我比赛的时候怀着内疚的心情偷偷的写了一个暴力的代码提交,结果AC了 - -bbb Posted by:cuiaoxiang at 2008-05-06 09:35:56 #include <stdio.h> #include <math.h> int n; double point[660][2]; double dis[660][660]; int main() { int cas; int i, j, k; double ans, tmp; double a, b, c; scanf("%d", &cas); while (cas-- > 0) { scanf("%d", &n); ans = 0.0; for (i = 0; i < n; i++) { scanf("%lf%lf", &point[i][0], &point[i][1]); } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { dis[i][j] = sqrt((point[i][0]-point[j][0])*(point[i][0]-point[j][0])+(point[i][1]-point[j][1])*(point[i][1]-point[j][1])); } } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { for (k = j + 1; k < n; k++) { a = dis[i][j]; b = dis[i][k]; c = dis[j][k]; tmp = a*b*c/sqrt((a+b+c)*(a+b-c)*(a+c-b)*(b+c-a)); if (tmp > ans) { ans = tmp; } } } } printf("%.3lf\n", ans); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator