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 |
多组数据都没有问题,到底哪出毛病了啊!哪位大哥帮忙看看啊!!!!!!!!!!!!#include "iostream" using namespace std; int pow(int ,int ); int ceil(int ,int ); void main() { int a1,a2,a3,a4,a5,a6; //每种木块的个数 int p1,p2,p3,p4,q,r,m,n; int Sum,sum;//需要的箱子数 do{ cin >>a1>>a2>>a3>>a4>>a5>>a6;//输入木块的数目 p1=(ceil(a3,4))*4-a3; //空余的3*3的个数 q=pow(2,p1)+1; //空余的3*3可放的2*2的个数 r=5*a4; //放4*4的箱子中可放的2*2的个数 n=11*a5;//方5*5的箱子中可放的1*1的个数 p2=ceil((a2-q-r),9); p3=ceil(a3,4); sum=a6+a5+a4+p3; if(q+r>=a2){ m=p1*9+5*a4*4-4*a2; p4=ceil((a1-(m+n)),36); if(m+n>=a1) Sum=sum; else Sum=sum+p4; } if(q+r<a2){ m=p1*9-q*4+(p2*9-(a2-q-r))*4; p4=ceil((a1-(m+n)),36); if(m+n>=a1) Sum=sum+p2; else Sum=sum+p4+p2; } if(Sum>0){ cout << Sum << endl; } }while(a1+a2+a3+a4+a5+a6!=0); } //求x的y次方 int pow(int x,int y) { int i; int num=1; for(i=0;i<y;i++){ num=num*x; } return num; } //求不小于s/t的最小整数 int ceil(int s,int t) { int w; if(s%t==0) w=s/t; else w=s/t+1; return w; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator