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 |
难道不是直接带公式计算? sample都过不了#include <iostream> #include <cstdio> #include <cmath> using namespace std; double x[52][52],y[52][52],z[52][52]; int main() { double ax,bx,cx,dx,ex,fx,gx,hx,ix,ay,by,cy,dy,ey,fy,gy,hy,iy,az,bz,cz,dz,ez,fz,gz,hz,iz; double vtx,vty,vtz,hu,vu,hfx,hfy,hfz,vfx,vfy,vfz,htx,hty,htz,nx,ny,nz,factor; int xx,yy,i,j; while (scanf("%d%d",&xx,&yy)!=EOF) { for (j=0;j<yy;++j) for (i=0;i<xx;++i) scanf("%lf%lf%lf",&x[i][j],&y[i][j],&z[i][j]); printf("%d\n",xx*yy); xx-=3; yy-=3; for (j=0;j<=yy;++j) for (i=0;i<=xx;++i) { ax=x[i][j]; bx=x[i][j+1]; cx=x[i][j+2]; dx=x[i+1][j]; ex=x[i+1][j+1]; fx=x[i+1][j+2]; gx=x[i+2][j]; hx=x[i+2][j+1]; ix=x[i+2][j+2]; ay=y[i][j]; by=y[i][j+1]; cy=y[i][j+2]; dy=y[i+1][j]; ey=y[i+1][j+1]; fy=y[i+1][j+2]; gy=y[i+2][j]; hy=y[i+2][j+1]; iy=y[i+2][j+2]; az=z[i][j]; bz=z[i][j+1]; cz=z[i][j+2]; dz=z[i+1][j]; ez=z[i+1][j+1]; fz=z[i+1][j+2]; gz=z[i+2][j]; hz=z[i+2][j+1]; iz=z[i+2][j+2]; hu=(ex-dx)*(dx-fx)+(ey-dy)*(dy-fy)+(ez-dz)*(dz-fz); vu=(ex-bx)*(bx-hx)+(ey-by)*(by-hy)+(ez-bz)*(bz-hz); hfx=(dy-fy)*(ez-dz)-(dz-fz)*(ey-dy); hfy=(dz-fz)*(ex-dx)-(dx-fx)*(ez-dz); hfz=(dx-fx)*(ey-dy)-(dy-fy)*(ex-dx); vfx=(by-hy)*(ez-bz)-(bz-hz)*(ey-by); vfy=(bz-hz)*(ex-bx)-(bx-hx)*(ez-bz); vfz=(bx-hx)*(ey-by)-(by-hy)*(ex-bx); vtx=(hy-ey)*vfz-(hz-ez)*vfy-(hx-ex)*vu; vty=(hz-ez)*vfx-(hx-ex)*vfz-(hy-ey)*vu; vtz=(hx-ex)*vfz-(hy-ey)*vfx-(hz-ez)*vu; htx=(fy-ey)*hfz-(fz-ez)*hfy-(fx-ex)*hu; hty=(fz-ez)*hfx-(fx-ex)*hfz-(fy-ey)*hu; htz=(fx-ex)*hfy-(fy-ey)*hfx-(fz-ez)*hu; nx=hty*vtz-htz*vty; ny=htz*vtx-htx*vtz; nz=htx*vty-hty*vtx; factor=1./sqrt(nx*nx+ny*ny+nz*nz); printf("%.4f %.4f %.4f\n",nx*factor,ny*factor,nz*factor); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator