-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB1024.java
More file actions
40 lines (31 loc) · 897 Bytes
/
B1024.java
File metadata and controls
40 lines (31 loc) · 897 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
31
32
33
34
35
36
37
38
39
40
package Practice;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B1024 { //¼ö¿ÀÇ ÇÕ
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int L = Integer.parseInt(st.nextToken());
for(int i = L; i <= 100; i++) {
StringBuilder sb = new StringBuilder();
int num = N / i, sum = 0;
num -= ((i % 2 == 0) ? i - 2 : i - 1) / 2;
if(num < 0) {
System.out.println(-1);
return ;
}
for(int j = 0; j < i; j++) {
sum += num;
sb.append(num++).append(' ');
}
if(sum == N) {
System.out.println(sb);
return;
}
}
System.out.println(-1);
}
}