-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask3082.java
More file actions
61 lines (51 loc) · 1.37 KB
/
Task3082.java
File metadata and controls
61 lines (51 loc) · 1.37 KB
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
60
61
import java.util.Scanner;
public class Task3082 {
public static final int LIMIT = 100_000;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int n = scanner.nextInt();
char min = 'A';
char max = 'B';
boolean real = false;
if (b < a) {
int tmp = a;
a = b;
b = tmp;
min = 'B';
max = 'A';
}
int bV = 0;
int count = 0;
do {
if (b - bV >= a) {
bV += a;
} else {
bV = a - (b - bV);
count++;
}
count++;
if (n == bV) {
real = true;
break;
}
} while (count < LIMIT);
if (real) {
bV = 0;
do {
System.out.printf(">%c\n", min);
System.out.printf("%c>%c\n", min, max);
if (b - bV >= a)
bV += a;
else {
bV = a - (b - bV);
System.out.printf("%c>\n", max);
System.out.printf("%c>%c\n", min, max);
}
} while (n != bV);
} else {
System.out.println("Impossible");
}
}
}