-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathP_13_1.java
More file actions
29 lines (27 loc) · 920 Bytes
/
Copy pathP_13_1.java
File metadata and controls
29 lines (27 loc) · 920 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
package aoc;
public final class P_13_1 {
public static void main(String[] args) {
final int n = 1000104;
final String input =
"41,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,37,x,x,x,x,"
+ "x,659,x,x,x,x,x,x,x,23,x,x,x,x,13,x,x,x,x,x,19,x,x,x,x,x,x,x,x,x,29,x,937,x,x,x,"
+ "x,x,x,x,x,x,x,x,x,x,x,x,x,17";
long res = (long) 1e18;
long smallest = (long) 1e18;
for (String split : input.split(",")) {
if ("x".equals(split)) {
continue;
}
final long curr = Long.parseLong(split);
long rem = n % curr;
if (rem > 0) {
rem = curr - rem;
}
if (smallest > rem) {
smallest = rem;
res = rem * curr;
}
}
System.out.println(res);
}
}