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 |
C++AC,G++WA。附拙劣代码#include<stdio.h> #include<math.h> struct point { double x,y; } p[40][40]; double cross(point a, point b, point c) { return 0.5*fabs((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y)); } double area(point a, point b, point c, point d) { return cross(a, b, c)+cross(d, c, b); } int main() { int n; double a[40],b[40],c[40],d[40]; while(~scanf("%d", &n)&&n) { p[0][0].x = p[0][0].y = 0; p[0][n+1].x = 1,p[0][n+1].y = 0; p[n+1][0].x = 0,p[n+1][0].y = 1; p[n+1][n+1].x = p[n+1][n+1].y = 1; for(int i = 1; i <= n; ++i) { scanf("%lf", &a[i]); p[0][i].x = a[i]; p[0][i].y = 0; } for(int i = 1; i <= n; ++i) { scanf("%lf", &b[i]); p[n+1][i].x = b[i]; p[n+1][i].y = 1; } for(int i = 1; i <= n; ++i) { scanf("%lf", &c[i]); p[i][0].x = 0; p[i][0].y = c[i]; } for(int i = 1; i <= n; ++i) { scanf("%lf", &d[i]); p[i][n+1].x = 1; p[i][n+1].y = d[i]; } for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) { p[i][j].x = ((b[j]-a[j])*c[i]+a[j])/(1.0-(b[j]-a[j])*(d[i]-c[i])); p[i][j].y = p[i][j].x*(d[i]-c[i])+c[i]; } double ans = 0; for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) { double temp = area(p[i][j], p[i][j+1], p[i+1][j], p[i+1][j+1]); if(temp > ans) ans = temp; } printf("%.6lf\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