- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1699.java
More file actions
Latest commit
26 lines (19 loc) · 508 Bytes
/
Copy path1699.java
File metadata and controls
26 lines (19 loc) · 508 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
importjava.util.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
intn = sc.nextInt();
int[] d = newint[n+1];
d[1] = 1;
for(inti=2; i<n+1; i++) {
intx = 1;
intmin = Integer.MAX_VALUE;
while(i-x*x >=0) {
min = Math.min(min, d[i-x*x]);
x++;
}
d[i] = min + 1;
}
System.out.println(d[n]);
}
}