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:留念,,,

Posted by 2001610107 at 2022-07-25 09:02:46 on Problem 1017
In Reply To:留念,,, Posted by:lvweihua at 2017-08-10 12:26:20
> #include<cstdio>
> #include<algorithm>
> using namespace std;
> int C[7]={0};  //N[1]--N[6]分别代表1-6号物品的个数
> int solve(){
>     int tol=C[6];
>     tol+=C[5];
>     C[1]=max(0,C[1]-11*C[5]);   //1号尽量多的往5号放置
>     tol+=C[4];
>     if(C[2]>=C[4]*5)            //2号箱子多
>         C[2]-=C[4]*5;
>     else{                       //2号箱子不够,用1号箱子补充
>         C[1]=max(0,C[1]-4*(5*C[4]-C[2]));
>         C[2]=0;
>     }
>     tol+=(C[3]+3)/4;            //每4个3号箱子放一个盒子,+3是为了防止小于4的时候,出现除法结果是0的情况
>     int mod=C[3]%4;
>     C[3]=0;
>     if(mod){                    //3号由剩余
>         if(C[2]>=7-2*mod){      //由剩余规律得出的,先找数的规律,然后再进行计算
>             C[2]-=7-2*mod;
>             C[1]=max(0,C[1]-(8-mod));
>         }
>         else{
>             C[1]=max(0,C[1]-(36-9*mod-4*C[2]));   //必然的,去掉3*3和2*2占用的,剩下的只能由1*1填补
>             C[2]=0;
>         }
>     }
>     tol+=(C[2]+8)/9;            //与C[3]+3的效果一样
>     mod=C[2]%9;
>     C[2]=0;
>     if(mod)
>         C[1]=max(0,C[1]-(36-4*mod));
>     tol+=(C[1]+35)/36;
>     return tol;
> }
> int main()
> {
>     while(1){
>         int t=0;
>         for(int i=1;i<=6;i++){
>             scanf("%d",&C[i]);
>             t+=C[i];
>         }
>         if(t==0)break;
>         printf("%d\n",solve());
>     }
>     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