File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.BufferedReader ;
3+ import java.io.IOException ;
4+ import java.io.InputStreamReader ;
5+ import java.util.Arrays ;
6+
7+ public class Main {
8+
9+ static long diff;
10+ static StringBuilder sb = new StringBuilder ();
11+
12+
13+ public static void main (String [] args ) throws IOException {
14+ init();
15+ process();
16+ print();
17+ }
18+
19+ private static void init () throws IOException {
20+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));;
21+ diff = Integer . parseInt(br. readLine());
22+ }
23+
24+ private static void process () {
25+
26+ long pre = 1l ;
27+ boolean isEmpty = true ;
28+ for (long i = 2 ; i <= 500000 ; i++ ) {
29+ long num = i* i;
30+ if (num - pre > diff) break ;
31+ pre = num;
32+
33+ long target = num - diff;
34+ if (target == 0 ) continue ;
35+ long sqrt = (long ) Math . sqrt(target);
36+ if (sqrt* sqrt != target) continue ;
37+ isEmpty = false ;
38+ sb. append(i). append(" \n " );
39+
40+
41+
42+ }
43+
44+ if (isEmpty)sb. append(" -1" );
45+
46+ }
47+
48+
49+
50+ private static void print () {
51+ System . out. println(sb. toString());
52+ }
53+ }
54+
55+
56+ ```
You can’t perform that action at this time.
0 commit comments