Advertisement
Guest User

d5.c

a guest
Jan 20th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 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(t=u;t<=v;++t)
  13.                 for(x=0;x<8;++x){
  14.                     cur=vec[x][0]*(a*t*t+b*t+c)+vec[x][1]*(d*t*t+e*t+f)+vec[x][2]*(g*t*t+h*t+i);
  15.                     best[x]=best[x]>cur?best[x]:cur;
  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