/* 주사위의 갯수
* 상자의 가로, 세로, 높이가 저장되어있는 배열 box와
* 주사위 모서리의 길이 정수 n이 매개변수로 주어졌을 때,
* 상자에 들어갈 수 있는 주사위의 최대 개수를 return
*
* box n result
* [1, 1, 1] 1 1
* [10, 8, 6] 3 12
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
public class programmer_0_79 {
static int[] a1 = {1,1,1}; static int b1 = 1;
static int[] a2 = {10,8,6}; static int b2 = 3;
public int solution(int[] box, int n) {
int answer = 1;
for(int i : box) answer *= i/n;
return answer;
}
public static void main(String args[]){
programmer_0_79 t = new programmer_0_79();
System.out.println("---------------------------------------");
System.out.println("result = " + t.solution(a1,b1));
System.out.println("---------------------------------------");
System.out.println("result2 = " + t.solution(a2,b2));
System.out.println("---------------------------------------");
// System.out.println("result3 = " + t.solution(a3,b3));
// System.out.println("---------------------------------------");
}
}
|
cs |