#23545: 想法


rakyjack (WaYe)

學校 : 國立中興大學
編號 : 103345
來源 : [49.217.174.139]
最後登入時間 :
2023-10-22 16:49:22
d502. 第三題:產品包裝 -- 98學年度高雄市資訊學科能力競賽 | From: [114.41.55.100] | 發表日期 : 2020-11-26 20:56

長度為1的可以最後再來討論

一個包裝盒可以有以下組合

    1. 長度4*1

    2. 長度3*1+長度1*37

    3. 長度2*8

如果長度2先全部8個裝成一盒,剩下的再來和長度1討論

以下是我的code(如果命名覺得很差,拜託鞭小力一點,我還是程式新手,還在學習命名)

#include <iostream>

using namespace std;

int main(){

int amountLength1,amountLength2,amountLength3,amountLength4,amountBox;

while(cin>>amountLength1>>amountLength2>>amountLength3>>amountLength4){

amountBox=0;

amountBox+=(amountLength4+amountLength3+amountLength2/8);

amountBox=amountLength2%8==0?amountBox:amountBox+1;

amountLength1-=(amountLength3*37+(8-amountLength2%8)*8);

amountBox=amountLength1<=0?amountBox:amountBox+amountLength1/64;

cout<<amountBox<<endl;

}

return 0;

}

 
ZeroJudge Forum