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 |
help why wrong?我的程序: #include<stdio.h> #include<math.h> int main() { double a,b; int grid,shew,temp,flag,k,flag2; int bottom; while(scanf("%lf%lf",&a,&b)!=EOF) { bottom=(int)a; //以a为底计算 temp=bottom; //bottom是最底层放pipe的个数 for(k=0;;k++) //k是最多放的层数 if(k*sqrt(3)/2+1>b) break; flag2=flag=0; if(a-(int)a>=0.5) flag2=1; //斜着放,每层可以都放bottom个 for(k=k-1;k>0;k--) { if(flag==0&&flag2==0) //temp是当前计算出的总数 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; //shew是歪着放可以放的总数 bottom=(int)b; //以b为底计算 temp=bottom; for(k=0;;k++) if(k*sqrt(3)/2+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; 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator