Advertisement
Guest User

d5-2.c

a guest
Jan 20th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3.     freopen("DATA5.txt","r",stdin);
  4.     freopen("OUT5.txt","w",stdout);
  5.     const static int vec[8][3]={{1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,-1,-1},{-1,-1,1},{-1,1,-1},{-1,1,1}};
  6.     int _,j;
  7.     for(_=5;_--;){
  8.         int best[8],max=-2147483647,a,b,c,d,e,f,g,h,i,u,v,t,x,cur;
  9.         for(x=0;x<8;best[x++]=max);
  10.         for(scanf("%i",&j);j--;){
  11.             scanf("%i%i%i%i%i%i%i%i%i%i%i",&a,&b,&c,&d,&e,&f,&g,&h,&i,&u,&v);
  12.             for(x=0;x<8;++x){
  13.                 int T[3]={u,v,(1-(vec[x][0]*b+vec[x][1]*e+vec[x][2]*h)/(vec[x][0]*a+vec[x][1]*d+vec[x][2]*g))/2};
  14.                 for(t=T[2]<u||T[2]>v?2:3;t--;best[x]=best[x]>cur?best[x]:cur)
  15.                     cur=vec[x][0]*(a*T[t]*T[t]+b*T[t]+c)+vec[x][1]*(d*T[t]*T[t]+e*T[t]+f)+vec[x][2]*(g*T[t]*T[t]+h*T[t]+i);
  16.             }
  17.         }
  18.         for(j=0;j<4;++j)
  19.             max=best[j]+best[j|4]>max?best[j]+best[j|4]:max;
  20.         printf("%i\n",max);
  21.     }
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement