-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem42.java
More file actions
38 lines (34 loc) · 813 Bytes
/
Problem42.java
File metadata and controls
38 lines (34 loc) · 813 Bytes
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
package dimikOJ;
import java.util.Scanner;
public class Problem42 {
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 > 100) {
T = input.nextInt();
}
input.nextLine();
int[] n = new int[T];
for (int i = 0; i < n.length; i++) {
int temp = input.nextInt();
while (temp < 0 || temp > 50) {
temp = input.nextInt();
}
n[i] = temp;
}
input.close();
for (int i = 0; i < n.length; i++) {
for (int j = n[i]; j >= 0; j--) {
if (j == 0) {
System.out.print(1);
} else if (j == 1) {
System.out.print(2 + " + ");
} else {
System.out.print(2 + "^" + j + " + ");
}
}
System.out.println();
}
}
}