-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem38.java
59 lines (49 loc) · 1.41 KB
/
Problem38.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package dimikOJ;
import java.util.Scanner;
public class Problem38 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int t = input.nextInt();
while (t < 1) {
t = input.nextInt();
}
input.nextLine();
String[] inputs = new String[t];
for (int i = 0; i < t; i++) {
String temp = input.nextLine();
String[] tempArray = temp.trim().replaceAll("\\s{2,}", " ").split("\\s");
int n = Integer.parseInt(tempArray[0]);
int m = Integer.parseInt(tempArray[1]);
while (n < 1 || n < m) {
temp = input.nextLine();
tempArray = temp.trim().replaceAll("\\s{2,}", " ").split("\\s");
n = Integer.parseInt(tempArray[0]);
m = Integer.parseInt(tempArray[1]);
}
inputs[i] = temp.trim().replaceAll("\\s{2,}", " ");
}
input.close();
for (int i = 0; i < inputs.length; i++) {
String[] tempArray = inputs[i].split("\\s");
int n = Integer.parseInt(tempArray[0]);
int m = Integer.parseInt(tempArray[1]);
int k = 0;
for (int j = 0; j < ((2 * n) - 1); j++) {
if (j < Math.ceil((2 * n) - 1) / 2) {
for (int j2 = 0; j2 < j + 1; j2++) {
System.out.print(m + " ");
k = j2;
}
} else {
for (int j2 = k; j2 > 0; j2--) {
System.out.print(m + " ");
}
k--;
}
System.out.println();
}
System.out.println();
}
}
}