Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:help why wrong?

Posted by fxzy at 2006-01-27 07:35:47 on Problem 1319
In Reply To:help why wrong? Posted by:fxzy at 2006-01-25 15:38:32
郁闷.少考虑了小于1的情况....
#include<stdio.h>
#include<math.h>
#define dd sqrt(3)/2
int main()
{   double a,b;
    int grid,shew,temp,flag,k,flag2;
    int bottom; 
	while(scanf("%lf%lf",&a,&b)!=EOF)
	 {
		 bottom=(int)a;
		 temp=bottom;
		 for(k=0;;k++)
		   if(k*dd+1.0>b)
		     break; 
		     
		     flag2=flag=0;
		     
		     if(a-(int)a>=0.5) flag2=1; 
	    for(k=k-1;k>0;k--)
	     { if(flag==0&&flag2==0)
	         temp+=bottom-1;  	 
		     if(flag==1&&flag2==0) temp+=bottom;
		      if(flag==0) flag=1;
		      else flag=0;
		    if(flag2==1) temp+=bottom;
		  }
		   shew=temp;
		   
		    bottom=(int)b;
		 temp=bottom;
		 for(k=0;;k++)
		   if(k*dd+1>a)
		     break; 
		     flag2=flag=0;
		      if(b-(int)b>=0.5) flag2=1; 
	    for(k=k-1;k>0;k--)
	      { if(flag==0&&flag2==0)
	          temp+=bottom-1;  	 
		      if(flag==1&&flag2==0) temp+=bottom;
		      if(flag==0) flag=1;
		      else flag=0;
		    if(flag2==1) temp+=bottom;
		  }
		 
		  if(temp>shew)
		       shew=temp;
		       
		  if(a<1||b<1)  {printf("0 grid\n");continue;}
		  
		   grid=(int)(a)*(int)(b);
		   
		  if(grid<shew)
		   printf("%d skew\n",shew);     
		 else printf("%d grid\n",grid);
		 }
	          return 0;
	}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator