-
Notifications
You must be signed in to change notification settings - Fork 3
/
CCC02S1.java
42 lines (42 loc) · 1.63 KB
/
CCC02S1.java
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
import java.io.*;
/**
* CCC '02 S1 - The Students' Council Breakfast
* Question type: Implementation
* 3/3 on DMOJ
* @author Tommy Pang
*/
public class CCC02S1 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int total = 0;
public static void main(String[] args) throws IOException {
int P = Integer.parseInt(br.readLine());
int G = Integer.parseInt(br.readLine());
int R = Integer.parseInt(br.readLine());
int O = Integer.parseInt(br.readLine());
int N = Integer.parseInt(br.readLine());
int min = 100000, combination = 0;
for (int i = 0; i < N/P + 1; i++) {
for (int j = 0; j < N/G + 1; j++) {
for (int k = 0; k < N/R + 1; k++) {
for (int l = 0; l < N/O + 1; l++) {
total += (i*P + j*G + k*R + l*O);
if (total == N) {
System.out.println("# of PINK is " + i + " # of GREEN is " + j + " # of RED is " + k + " # of ORANGE is " +l);
min = Math.min(min, i+j+k+l);
combination+=1;
total=0;
}
total=0;
}
total=0;
}
total=0;
}
total=0;
}
System.out.println("Total combinations is " + combination + ".");
System.out.println("Minimum number of tickets to print is " + min + ".");
}
}