No.27 Preparing Boards
タグ : / 解いたユーザー数 246
作問者 :
nmnmnmnmnmnmnm
Problem Statement
You can prepare an unlimited number of boards of three different lengths A, B, and C.
You may freely choose A, B, and C as integer values.
Boards can be joined together to extend their length.
You want to make boards of the specified lengths V0, V1, V2, and V3.
What is the minimum number of boards required?
Input
V0 V1 V2 V3
Four specified board lengths (V0,V1,V2,V3) are given.
They are integers with 1<=V0,V1,V2,V3<=30, and Vi=Vj (0<=i,j<=3) may hold.
Output
Output the required number of boards as a string, followed by a newline at the end.
Sample
Sample 1
Input
28 29 30 30
Output
4
One board of A=28, one board of B=29, and two boards of C=30 are needed, for a total of 4 boards.
Sample 2
Input
2 3 7 15
Output
6
Three boards of A=2, two boards of B=3, and one board of C=15 are needed, for a total of 6 boards.
7 can be made by joining two boards of A and one board of B.
Sample 3
Input
3 6 11 20
Output
5
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。