[SWEA] 두가지 빵의 딜레마

문제 보러가기

제한사항

이외의 제한사항은 없다.

첫번째 생각

더 적은 빵을 여러개 사는것으로 계산한다.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int A = s.nextInt();
			int B = s.nextInt();
			int C = s.nextInt();
			int res = 0;
			if (A>B) {
				res = C/B;
			}
			else
				res = C/A;
			
			System.out.println("#"+tc+" "+res);
		}
	}

}