-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2028.java
More file actions
73 lines (60 loc) · 1.73 KB
/
2028.java
File metadata and controls
73 lines (60 loc) · 1.73 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package algo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
private static int T;
private static int[] N;
public static void main(String[] args) throws IOException {
InputClass.input();
new Solution().run(N);
InputClass.close();
}
static class InputClass {
public static final BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
public static final BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out));
private static StringTokenizer st = null;
public static void input() throws IOException {
st = getStringTokenizer();
T = Integer.parseInt(st.nextToken());
N = new int[T];
int idx = 0;
while(idx < T) {
st = getStringTokenizer();
N[idx++] = Integer.parseInt(st.nextToken());
}
}
public static void close() throws IOException {
BR.close();
BW.close();
}
public static StringTokenizer getStringTokenizer() throws IOException {
return new StringTokenizer(InputClass.BR.readLine(), " ");
}
}
static class Solution {
public void run(int[] N) throws IOException {
int len = N.length;
int idx = 0;
while(idx < len) {
InputClass.BW.write(square(N[idx++]) + "\n");
}
}
public String square(int n) {
String squareStr = String.valueOf(n * n);
String convertToN = String.valueOf(n);
int idx1 = squareStr.length() - 1;
int idx2 = convertToN.length() - 1;
int len = convertToN.length();
for(int i=0; i<len; i++) {
if(squareStr.charAt(idx1--) != convertToN.charAt(idx2--)) {
return "NO";
}
}
return "YES";
}
}
}