File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.util.* ;
3+ import java.io.* ;
4+
5+ public class Main {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
8+ static StringBuilder sb = new StringBuilder ();
9+ static int G ;
10+
11+ public static void main (String [] args ) throws Exception {
12+ G = Integer . parseInt(br. readLine());
13+ List<Integer > results = new ArrayList<> ();
14+ for (int b = 1 ; b * b <= G ; b++ ) {
15+ if (G % b == 0 ) {
16+ int a = G / b;
17+
18+ if ((a + b) % 2 == 0 ) {
19+ int c = (a + b) / 2 ;
20+ int p = (a - b) / 2 ;
21+
22+ if (p >= 1 ) {
23+ results. add(c);
24+ }
25+ }
26+ }
27+ }
28+
29+ if (results. isEmpty()) {
30+ bw. write(" -1" );
31+ } else {
32+ Collections . sort(results);
33+ for (int weight : results) {
34+ bw. write(weight + " \n " );
35+ }
36+ }
37+
38+ bw. close();
39+ }
40+ }
41+ ```
You can’t perform that action at this time.
0 commit comments