-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask626C.java
More file actions
30 lines (28 loc) · 763 Bytes
/
Task626C.java
File metadata and controls
30 lines (28 loc) · 763 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
import java.util.*;
public class Task626C {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n, m;
n = s.nextInt();
m = s.nextInt();
int nl = 2 * n;
int ml = 3 * m;
int c = Math.min(nl, ml) / 6;
for(int i = 1; i <= c; i++) {
if(nl <= ml) {
nl += 2;
if(nl % 3 == 0 && ml >= nl)
nl += 2;
} else {
ml += 3;
if(ml % 2 == 0 && nl >= ml) {
if(ml < nl)
ml += 3;
else
nl += 2;
}
}
}
System.out.println(Math.max(nl, ml));
}
}