-
Notifications
You must be signed in to change notification settings - Fork 2
/
Solution.java
53 lines (47 loc) · 1.15 KB
/
Solution.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
package com.algorithm.playground.google.codejam._2019.qualification.foregonesolution;
import java.util.Scanner;
/**
* https://codingcompetitions.withgoogle.com/codejam/round/0000000000051705/0000000000088231
*/
public class Solution {
public static void main(String[] args) {
try (Scanner console = new Scanner(System.in)) {
int tests = console.nextInt();
for (int test = 1; test <= tests; test++) {
int[][] ans = solve(console.next().trim());
System.out.print(String.format("Case #%s: ", test));
print(ans[0]);
System.out.print(" ");
print(ans[1]);
System.out.println();
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
private static void print(int[] n) {
int idx = 0;
for (; idx < n.length; idx++) {
if (n[idx] != 0) {
break;
}
}
for (; idx < n.length; idx++) {
System.out.print(n[idx]);
}
}
static int[][] solve(String n) {
int[] a = new int[n.length()];
int[] b = new int[n.length()];
for (int i = 0; i < n.length(); i++) {
char ch = n.charAt(i);
if (ch == '4') {
b[i] = 1;
a[i] = 3;
} else {
a[i] = ch - '0';
}
}
return new int[][]{a, b};
}
}