-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA 1244 - Pens and Pencils.java
43 lines (36 loc) · 1.01 KB
/
A 1244 - Pens and Pencils.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
43
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] data = new int[input.nextInt()][5];
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
data[i][j] = input.nextInt();
}
}
int a, b, c, d, k;
int pen, pencil;
for (int i = 0; i < data.length; i++) {
pen = 0;
pencil = 0;
a = data[i][0];
b = data[i][1];
c = data[i][2];
d = data[i][3];
k = data[i][4];
while (a > 0) {
pen++;
a = a - c;
}
while (b > 0) {
pencil++;
b = b - d;
}
if ((pen + pencil) <= k) {
System.out.println(pen + " " + pencil);
} else {
System.out.println(-1);
}
}
}
}